关于ActionEvent问题
package aaa;import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class demo1 extends JFrame {
JTextArea Area = new JTextArea(6,40);
JTextField tf1= new JTextField(15);
JTextField tf2=new JTextField(15);
public demo1(){
add(Area);
add(new JLabel("name"));
add(tf1);
add(new JLabel("身份证"));
add(tf2);
tf1.addActionListener(new ActionLis());
tf2.addActionListener(new ActionLis());
}
class ActionLis implements ActionListener{
public void actionperformed(ActionEvent e){
if(e.getSource()==tf1)
Area.append("姓名"+tf1.getText()+"/n");
else
Area.append("身份证"+tf1.getText()+"/n");
}
}
public static void main(String arg[]){
demo1 d=new demo1();
d.setTitle("aaa");
FlowLayout f=new FlowLayout();//逐行布局
d.setLayout(f);
Dimension ScreenSize=Toolkit.getDefaultToolkit().getScreenSize(); /*获取屏幕大小*/
Dimension frameSize=d.getSize();/*表单大小*/
d.setLocation((ScreenSize.width-frameSize.width)/2,(ScreenSize.height-frameSize.height)/2);/*居中显示*/
d.setVisible(true);
d.setSize(300,100);
}
用eclipse运行的时候 为什么ActionLis这个地方有错误,哪位高手指点一下谢谢