JTextArea监听器

来源:百度知道 编辑:UC知道 时间:2024/06/04 00:39:08
符号: 方法 addActionListener(<匿名 java.awt.event.ActionListener>)
位置: 类 javax.swing.JTextArea
t4.addActionListener(new ActionListener()
^
t4= new JTextArea(); //对话窗口
t4.setEnabled(false);
t4.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
sendData(t4.getText());
}
});
如果可以请帮忙修改

1.t4需要定义为final JTextArea t4=new JTextArea(),因为他下面要被做为局部变量传递给匿名内部类。
2.如果你是在main函数中运行该方法,sendData必须定义为static。

JTextArea没有addActionListener方法,JTextField有