-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
x86
-
windows_2000
Name: bsC130419 Date: 06/18/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
If a user types a space while editting the contents of an editable JComboBox,
the space triggers the combo to pop open instead of being passed
through to the editor. This is a moderate annoyance.
Source code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ComboTest extends JFrame implements ActionListener {
JComboBox combo = new JComboBox();
public ComboTest() {
JButton ok = new JButton("OK");
JPanel panel = new JPanel();
// initialization
combo.addItem("item one");
combo.addItem("item two");
combo.setEditable(true);
// handlers
ok.addActionListener(this);
// layout
panel.setLayout(new GridLayout(2, 1));
panel.add(combo);
panel.add(ok);
setContentPane(panel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
public void actionPerformed(ActionEvent e) {
Object text = combo.getSelectedItem();
System.out.println("ComboBox contains: " + text);
}
public static void main(String[] args) {
ComboTest test = new ComboTest();
test.setVisible(true);
}
}
(Review ID: 126724)
======================================================================