-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Name: rm29839 Date: 02/02/98
The setEnabled(boolean b) method of AbstractAction, does not disable the Button it was added to, nor does it prevent the
actionPerformed method of the AbstractAction implementation from being called.
source
------
import com.sun.java.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Test extends JFrame {
public static void main(String [] args) {
JFrame f = new Test();
f.pack();
f.setVisible(true);
}
public Test() {
super("Test");
_action = new AbstractAction() {
public void actionPerformed(ActionEvent ev) {
System.out.println("performed");
}
public void setEnabled(boolean b) {
super.setEnabled(b);
System.out.println(b);
}
};
JButton button = new JButton("Test");
button.addActionListener(_action);
JButton button2 = new JButton("Disable");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
System.out.println("Disable");
_action.setEnabled(false);
}
}
);
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(button);
this.getContentPane().add(button2);
}
Action _action;
}
----
javac Test.java
java Test
true
performed
performed
Disable
false
performed
(Review ID: 24327)
======================================================================