这是我的代码:
import javax.swing.*;
import java.awt.*;
public class FirstGui extends JFrame {
private JLabel label;
private JButton button;
public FirstGui() {
setLayout(new FlowLayout());
button = new JButton("Click for sex");
add(button);
label = new JLabel("");
add(label);
event e = new event();
button.addActionListener(e);
}
public class event implements ActionListener {
public void actionPerformed(ActionEvent e) {
label.setText("how you can see wors here");
}
}
public static void main(String [] args) {
FirstGui gui = new FirstGui();
gui.setDefaultCloseOperation(EXIT_ON_CLOSE);
gui.setSize(200, 200);
gui.setTitle("Title");
gui.setVisible(true);
}
}
并且它产生一个错误:
无法将ActionEvent解析为FirstGui.java / Test / src类型的行26 Java问题
无法将ActionListener解析为类型FirstGui.java / Test / src第24行Java问题
类型AbstractButton中的方法addActionListener(ActionListener)不适用于参数(FirstGui.event)FirstGui.java / Test / src第21行Java问题
有什么问题吗???我是Java新手.