我想编译这个类:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Main implements ActionListener {
private static JFrame frm = new JFrame();
private static JLabel username = new JLabel("User:");
private static JLabel password = new JLabel("Pass:");
private static JTextField username_field = new JTextField();
private static JPasswordField password_field = new JPasswordField();
private static ButtonGroup bg = new ButtonGroup();
private static JCheckBox sp = new JCheckBox ("Singleplayer");
private static JCheckBox mp = new JCheckBox("Multiplayer");
private static JButton play = new JButton("Play");
private static JPanel p = new JPanel();
public static void main(String[] args) {
new Main().initFrame();
}
public void initFrame() {
//Init Frame Stuff
}
public void actionPerformed(ActionEvent evt) {
if (evt.getActionCommand().equals("play")) {
//Other Stuff
}
}
}
正如你在上面看到的,我已经导入了 ActionListener,但是如果我编译代码,我会得到一个未知符号错误:
.\GamePanel.java:3: error: cannot find symbol
public class GamePanel extends JPanel implements ActionListener {
symbol: class ActionListener
1 error
为什么我会收到此错误?