Java 动作事件

Java ActionEvent

我的 Java ActionEvent 有问题,因为我的代码很大..

我收到这个错误:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem: 
The code of method actionPerformed(ActionEvent) is exceeding the 65535 bytes limit

我尝试了多种想法,但没有任何效果,例如:

我又添加了一个 ActionEvent

public void actionPerformed(ActionEvent ae) {

但出现错误:

Duplicate method actionPerformed(ActionEvent)

Eclipse 告诉我,重命名方法 tp "actionPerformed2"。如果我这样做,代码可以工作,但是如果我按下按钮,什么也不会发生,就像这样:

public void actionPerformed2(ActionEvent ae) {
if(ae.getSource() == jbtnBuildCarLv1){

既然消息只是告诉你你的方法太长了,那就分开吧。

此外,您不能只使用两个同名的方法,但如果您重命名一个方法,除非您手动执行此操作,否则将不会调用该方法。