-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
solaris_8
-
generic
-
solaris_8
jim.marks@Eng 1999-12-03
JCheckBox and JComboBox behave differently with respect to even generation
for code-triggered actions (as opposed to user-triggered).
To reproduce the problem:
1. Write a program which uses both JCheckBox and JComboBox.
2. Add an ActionListener for instances of each of the above classes. Put
a println() at the top of each of the actionPerfomed handlers.
3. As part of the constructor for the main class, call
<checkbox>.setSelected(true).
<combobox>.setSelectedIndex(<some-valid-index>.
4. You should see that the println() for the combo box is executed, but
the one for the checkbox is not executed.
Looks like the JCheckBox case (via setPressed function of JToggleButton)
causes a ChangeEvent only, whereas setSelectedIndex of JComboBox
causes both a ChangeEvent and ActionEvent to be triggered. From the
application writer's perspective, it would be helpful if these the behavior
was normalized across all Swing components.