Details
-
Bug
-
Resolution: Fixed
-
P3
-
7u6
-
b22
-
windows_7
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8048390 | 8u25 | Unassigned | P3 | Resolved | Fixed | b05 |
JDK-8044438 | 8u20 | Sergey Malenkov | P3 | Resolved | Fixed | b20 |
JDK-8053648 | emb-8u26 | Unassigned | P3 | Resolved | Fixed | b17 |
Description
FULL PRODUCT VERSION :
1.7.0_06
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 6.1.7601
A DESCRIPTION OF THE PROBLEM :
If you use a JComboBox as it's own ActionListener you will get unexpected behaviour:
The entries become (visually) unselectable.
This problem encounters especially when inheriting a class from JComboBox that implements an ActionListener
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create a (not-empty) JComboBox
2. use it as it's own ActionListener
3. add it to a Window/Dialog/Frame/Panel and run it
4. select an entry, different from the first one
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An entry should get selected
ACTUAL -
No entry is selected
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
JDialog dialog = new JDialog();
String[] entries = { " Cats " , " Porn " , " Lazors " , " Memes " };
// here starts the relevant part
JComboBox<String> myComboBox = new JComboBox<String>(entries);
myComboBox.addActionListener(myComboBox);
// here ends the relevant part
dialog.add(myComboBox);
dialog.pack();
dialog.setVisible(true);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
If you need to inherit a class from JComboBox and you want to have it's own Listener, don't use ActionListener, use ItemListener instead.
1.7.0_06
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 6.1.7601
A DESCRIPTION OF THE PROBLEM :
If you use a JComboBox as it's own ActionListener you will get unexpected behaviour:
The entries become (visually) unselectable.
This problem encounters especially when inheriting a class from JComboBox that implements an ActionListener
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create a (not-empty) JComboBox
2. use it as it's own ActionListener
3. add it to a Window/Dialog/Frame/Panel and run it
4. select an entry, different from the first one
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An entry should get selected
ACTUAL -
No entry is selected
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
JDialog dialog = new JDialog();
String[] entries = { " Cats " , " Porn " , " Lazors " , " Memes " };
// here starts the relevant part
JComboBox<String> myComboBox = new JComboBox<String>(entries);
myComboBox.addActionListener(myComboBox);
// here ends the relevant part
dialog.add(myComboBox);
dialog.pack();
dialog.setVisible(true);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
If you need to inherit a class from JComboBox and you want to have it's own Listener, don't use ActionListener, use ItemListener instead.
Attachments
Issue Links
- backported by
-
JDK-8044438 Use JComboBox as it's own ActionListener leads to unexpected behaviour
-
- Resolved
-
-
JDK-8048390 Use JComboBox as it's own ActionListener leads to unexpected behaviour
-
- Resolved
-
-
JDK-8053648 Use JComboBox as it's own ActionListener leads to unexpected behaviour
-
- Resolved
-
- relates to
-
JDK-8057893 JComboBox actionListener never receives "comboBoxEdited" from getActionCommand
-
- Resolved
-
-
JDK-8072767 DefaultCellEditor for comboBox creates ActionEvent with wrong source object
-
- Resolved
-