-
Bug
-
Resolution: Fixed
-
P4
-
7.0.0_01, 1.4.0, 1.4.2, 5.0u12
-
b50
-
x86, sparc
-
solaris_9, windows_nt, windows_xp
Name: sv35042 Date: 10/18/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION : Windows NT Version 4.0
A DESCRIPTION OF THE PROBLEM :
This is a list of the problems I encountered while using
JComboBox. Some have already been reported before but I am
putting it all together here in the hope someone will
notice.
1) There doesnt seem to be any way of cancelling the
selection made through the popup menu of the combo box.
PopupMenuListener.popupMenuCanceled() is never called.
2) The Up and Down arrow keys are supposed to navigate
through the popup menu of the combo box. What actually
happens is, the item gets selected and an ActionEvent is
fired(Placing the mouse on an item does not select it)
3) Placing the mouse on an item and then pressing the Enter
key does not select the item.
4) On Win32 platforms, pressing the Escape key after
navigating through the popup is supposed to restore the
original value. However, this does not happen because the
selection changes when we navigate.
5) On Win32 platforms, the Windows+F4 key is supposed to
toggle the popup menu. Java has no mapping for the Windows
key and so, nothing happens when this key combination is
pressed.
6) The API documentation says Alt+Up/Down is supposed to
toggle the menu. This does not happen when the look and
feel is Win32.
7) Editing a value fires two ActionEvents on the combo box.
8) Using the Enter key to select an item from the menu
first fires a PopupMenuEvent and then an ActionEvent. If
the mouse is used, the ActionEvent is fired first and then
the PopupMenuEvent.
9) The height of the "Files Of Type" combo box in the
JFileChooser dialog is greater than the height of the text
field and buttons when the look and feel is Win32.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the included the source code on a Win32 platform and
use a combination of the mouse and keyboard to edit and
select items. The print statements will print the events in
the order they occur.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
class BuggyComboBox extends JComboBox
{
public BuggyComboBox()
{
super();
setEditable(true);
addItems();
addListeners();
setSelectedItem("Item 10");
return;
}
protected void addListeners()
{
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Action performed!");
return;
}
});
addPopupMenuListener(new PopupMenuListener()
{
public void popupMenuWillBecomeVisible(PopupMenuEvent e)
{
System.out.println("Popup menu will become
visible!");
return;
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent
e)
{
System.out.println("Popup menu will become
invisible!");
return;
}
public void popupMenuCanceled(PopupMenuEvent e)
{
System.out.println("Popup cancelled!");
return;
}
});
return;
}
protected void addItems()
{
addItem("Item 1");
addItem("Item 2");
addItem("Item 3");
addItem("Item 4");
addItem("Item 5");
addItem("Item 6");
addItem("Item 7");
addItem("Item 8");
addItem("Item 9");
addItem("Item 10");
return;
}
public static void main(String args[])
{
try
{
UIManager.setLookAndFeel
(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{}
JFrame frame = new JFrame("Buggy Combo Box");
BuggyComboBox comboBox = new BuggyComboBox();
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
comboBox.setBounds(25, 25, 100, 25);
frame.getContentPane().setLayout(null);
frame.getContentPane().add(comboBox);
frame.setBounds((scrSize.width - 155) >> 1, (scrSize.height -
100) >> 1,
155, 100);
frame.setVisible(true);
return;
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
I added ActionListeners, KeyListeners and
PopupMenuListeners to the combo box and its editor and set
some flags to track where the call was coming from. Then,
based on the flags, I took appropriate action. But having
to do this every time is a real pain!
(Review ID: 159293)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION : Windows NT Version 4.0
A DESCRIPTION OF THE PROBLEM :
This is a list of the problems I encountered while using
JComboBox. Some have already been reported before but I am
putting it all together here in the hope someone will
notice.
1) There doesnt seem to be any way of cancelling the
selection made through the popup menu of the combo box.
PopupMenuListener.popupMenuCanceled() is never called.
2) The Up and Down arrow keys are supposed to navigate
through the popup menu of the combo box. What actually
happens is, the item gets selected and an ActionEvent is
fired(Placing the mouse on an item does not select it)
3) Placing the mouse on an item and then pressing the Enter
key does not select the item.
4) On Win32 platforms, pressing the Escape key after
navigating through the popup is supposed to restore the
original value. However, this does not happen because the
selection changes when we navigate.
5) On Win32 platforms, the Windows+F4 key is supposed to
toggle the popup menu. Java has no mapping for the Windows
key and so, nothing happens when this key combination is
pressed.
6) The API documentation says Alt+Up/Down is supposed to
toggle the menu. This does not happen when the look and
feel is Win32.
7) Editing a value fires two ActionEvents on the combo box.
8) Using the Enter key to select an item from the menu
first fires a PopupMenuEvent and then an ActionEvent. If
the mouse is used, the ActionEvent is fired first and then
the PopupMenuEvent.
9) The height of the "Files Of Type" combo box in the
JFileChooser dialog is greater than the height of the text
field and buttons when the look and feel is Win32.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the included the source code on a Win32 platform and
use a combination of the mouse and keyboard to edit and
select items. The print statements will print the events in
the order they occur.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
class BuggyComboBox extends JComboBox
{
public BuggyComboBox()
{
super();
setEditable(true);
addItems();
addListeners();
setSelectedItem("Item 10");
return;
}
protected void addListeners()
{
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Action performed!");
return;
}
});
addPopupMenuListener(new PopupMenuListener()
{
public void popupMenuWillBecomeVisible(PopupMenuEvent e)
{
System.out.println("Popup menu will become
visible!");
return;
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent
e)
{
System.out.println("Popup menu will become
invisible!");
return;
}
public void popupMenuCanceled(PopupMenuEvent e)
{
System.out.println("Popup cancelled!");
return;
}
});
return;
}
protected void addItems()
{
addItem("Item 1");
addItem("Item 2");
addItem("Item 3");
addItem("Item 4");
addItem("Item 5");
addItem("Item 6");
addItem("Item 7");
addItem("Item 8");
addItem("Item 9");
addItem("Item 10");
return;
}
public static void main(String args[])
{
try
{
UIManager.setLookAndFeel
(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{}
JFrame frame = new JFrame("Buggy Combo Box");
BuggyComboBox comboBox = new BuggyComboBox();
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
comboBox.setBounds(25, 25, 100, 25);
frame.getContentPane().setLayout(null);
frame.getContentPane().add(comboBox);
frame.setBounds((scrSize.width - 155) >> 1, (scrSize.height -
100) >> 1,
155, 100);
frame.setVisible(true);
return;
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
I added ActionListeners, KeyListeners and
PopupMenuListeners to the combo box and its editor and set
some flags to track where the call was coming from. Then,
based on the flags, I took appropriate action. But having
to do this every time is a real pain!
(Review ID: 159293)
======================================================================
- duplicates
-
JDK-6531772 JComboBox - Alt + UP/Down arrow keys do not expand/collapse the Combobox's list
- Closed
- relates to
-
JDK-6428549 REGRESSION: Text entered in the Editable JComboBox got cleared when the Enter Key is pressed
- Closed
-
JDK-6550847 Action events not firing in JCombox's selected item
- Closed