このクラスをコンパイルしたい:
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
なぜこのエラーが発生するのですか?