JButton滞后和ActionListener不起作用

您好,我正在用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);
    }
}

from: https://dev.to//calin92540842/jbutton-lagging-and-actionlistener-not-working-1jac

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值