我收到此错误请帮助:我收到私有类thehandler的错误,这是"类型第二个thehandler必须实现摘要 方法ActionListener.actionPerformed(ActionEvent)
注意:导入导入。我想要一个解决方案,但不是抽象的,因为它因某些原因导致整个程序崩溃。
public class Second extends JFrame {
private JTextField item1;
private JTextField item2;
private JTextField item3;
private JPasswordField itemp;
public Second(){
super("Game");
setLayout(new FlowLayout());
item1 = new JTextField(10);
add(item1);
item2 = new JTextField("Enter Text Here");
add(item2);
item3 = new JTextField("uneditable",20);
item3.setEditable(false);
add(item3);
itemp = new JPasswordField("PASSWORD");
add(itemp);
thehandler handler = new thehandler();
item1.addActionListener(handler);
item2.addActionListener(handler);
item3.addActionListener(handler);
itemp.addActionListener(handler);
}
private class thehandler implements ActionListener{
public void ActionPerformed(ActionEvent event){
String string = "";
if(event.getSource()==item1)
string = String.format("It's: %s", event.getActionCommand());
else if(event.getSource()==item2)
string = String.format("It's: %s", event.getActionCommand());
else if(event.getSource()==item3)
string = String.format("It's: %s", event.getActionCommand());
else if(event.getSource()==itemp)
string = String.format("It's: %s", event.getActionCommand());
JOptionPane.showMessageDialog(null, string);
}
}
}
答案 0 :(得分:5)
Java区分大小写
@Override
public void actionPerformed(ActionEvent event) {