您好,我正在用Java打造Java应用程序制造商, 我最近开始开发,刚按下一个按钮, 当我按下它时,点击纹理会停留很长时间 (只要我的鼠标继续悬停在按钮上)以及何时 单击它,我的ActionListener无法正常工作,我收到错误消息:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
The type new ActionListener(){} must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
这是代码,并且 提前致谢:
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.nio.*;
import java.util.*;
public class AppBuilder {
public static JFrame applicationWindow = new JFrame("Java Application Builder v0.1.0");
public static JButton buildButton = new JButton("Build Application!");
public static JTextField applicationTitle = new JTextField("New Application");
static {
applicationWindow.setLayout(new FlowLayout());
applicationWindow.add(new JLabel("Title:"));
applicationWindow.setSize(650,650);
applicationWindow.setMinimumSize(new Dimension(650,650));
applicationWindow.setLocationRelativeTo(null);
applicationWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
applicationWindow.getContentPane().setBackground(new Color(255,245,245));
applicationTitle.setSize(new Dimension(350,100));
buildButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("TEST");
}
});
}
public static void main(String[] args) {
applicationWindow.pack();
applicationWindow.setVisible(true);
applicationWindow.add(applicationTitle);
applicationWindow.add(buildButton);
}
}