Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
Name: rmT116609 Date: 08/03/2004 FULL PRODUCT VERSION : java version "1.5.0-beta2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51) Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Linux gaz 2.4.18 #18 SMP Mon Feb 24 11:42:05 EST 2003 i686 unknown EXTRA RELEVANT SYSTEM CONFIGURATION : KDE 3.2 A DESCRIPTION OF THE PROBLEM : I have an editable JComboBox with a focus listener on the editor. The ComboBox does not respond to arrow keys. It works fine if I remove the focus listener. This is a regression since it worked in 1.4.2. The arrow keys cannot be used to select items in the combobox. This same code works fine on Windows. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile and run the example. Use the mouse to pull down the combo box. Use the arrow keys to navigate down the drop-down list. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - I expect the arrow keys to cause the selection to change. ACTUAL - No response from the arrow keys. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import javax.swing.*; import java.awt.*; import java.awt.event.*; public class TestComboJFrame extends JFrame { private static TestComboJFrame sTest; private JComboBox fCombo; private DefaultComboBoxModel fComboModel; private ComboActionListener fActionListener; private String fCurrentItem; public TestComboJFrame() { sTest = this; setTitle("Test Frame"); JPanel innerPanel = new JPanel(new BorderLayout()); JToolBar tool = new JToolBar(); fCombo = new JComboBox(new String[] {"test1", "foo", "bar", "abc", "def"}); //I normally have a combo model here, but it doesn't matter for the test case. fCombo.setEditable(true); fActionListener = new ComboActionListener(); fCombo.addActionListener(fActionListener); fCombo.getEditor().getEditorComponent().addFocusListener(new FocusTracker()); tool.add(fCombo); innerPanel.add(tool, BorderLayout.NORTH); setTitle("Test Combo"); JTextArea textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setPreferredSize(new Dimension(400,400)); innerPanel.add(textArea, BorderLayout.CENTER); getContentPane().add(innerPanel); sTest.setSize(400, 400); sTest.setVisible(true); } public static void main(String[] args) { new TestComboJFrame(); } /** * Updates the combo box content and selection in response to focus events */ private class FocusTracker implements FocusListener { public void focusGained(FocusEvent event) { if (fCombo != null && fCombo.getEditor() != null) { fCombo.getEditor().selectAll(); } } public void focusLost(FocusEvent event) { } } private class ComboActionListener implements ActionListener { public void actionPerformed(ActionEvent event) { // put this on the AWT thread to make sure the popup is dismissed before we // process the event, if the popup was in fact dismissed by the user. SwingUtilities.invokeLater(new ComboboxActionPerformedThread()); } } private class ComboboxActionPerformedThread implements Runnable { public void run() { if (!fCombo.isPopupVisible()) { System.out.println("combo change accepted"); } } } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : None, other than removing the focus listener. Release Regression From : 1.4.2 The above release value was the last known release where this bug was known to work. Since then there has been a regression. (Incident Review ID: 290422) ======================================================================
|