optimal
asked on
JComboBox disappearing drop down button
Hi,
I'm using the Swing1.02 JComboBox component setting its 'Editable' data member to true ('setEditable(true)').
As a result the user can insert free text, but whenever he's writing, the drop down button on the right is disappearing. After changing the focus to some other component the button re-appears.
I checked the SwingSet demo and over there the JComboBox appears as it should (always).
From the sources I could not find any differences between the SwingSet way of JComboBox usage and mine.
If anyone knows how I may ask the JComboBox component to show the dropdown button always, I would most appriciate it.
Thanks in advance,
Guy Loewy.
Optimal Technologies, Inc.
I'm using the Swing1.02 JComboBox component setting its 'Editable' data member to true ('setEditable(true)').
As a result the user can insert free text, but whenever he's writing, the drop down button on the right is disappearing. After changing the focus to some other component the button re-appears.
I checked the SwingSet demo and over there the JComboBox appears as it should (always).
From the sources I could not find any differences between the SwingSet way of JComboBox usage and mine.
If anyone knows how I may ask the JComboBox component to show the dropdown button always, I would most appriciate it.
Thanks in advance,
Guy Loewy.
Optimal Technologies, Inc.
Could you post a piece of code showing the unexpected behaviour?
ASKER
The following code is part of "SearchPanel" class which extends JPanel, and
it appears in the constructor of that class.
// treeSearch JComboBox:
treeSearchCB = new JComboBox();
treeSearchCB.setEditable(t rue);
treeSearchCB.setBounds(45, 70, 120, 20);
this.add(treeSearchCB);
it appears in the constructor of that class.
// treeSearch JComboBox:
treeSearchCB = new JComboBox();
treeSearchCB.setEditable(t
treeSearchCB.setBounds(45,
this.add(treeSearchCB);
I can't reproduce your problem (I used the Metal L&F). However, if I had to make just a single try, it would be to change the way the layout is done. You should indeed use the layout managers instead of placing yourself the components. When you are placing yourself a component, you are in fact making strong hypothesis on the way it will be displayed. For example, if you switch the L&F to something else than what you are currently using, your interface will probably be in a bad shape...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Dufort,
I'm not adding the JComboBox directly to a JFrame. The Object is added to a JPanel component, therefor, I can't use "getContentPane()" which is a JFrame/JApplet method. The JPanel itself is being added using the "getContentPane().add(MyJP anel)" to the JApplet.
Second, I do understand the importence of layout managers, but since the JPanel to which I add the JComboBox is really a complex one, I preferred to use "null" layout. In JBuilder there is a XYLayout that acts the same way a "null" layout does but that makes my applet too big (and too slow to download).
Thanks anyway.
I'm not adding the JComboBox directly to a JFrame. The Object is added to a JPanel component, therefor, I can't use "getContentPane()" which is a JFrame/JApplet method. The JPanel itself is being added using the "getContentPane().add(MyJP
Second, I do understand the importence of layout managers, but since the JPanel to which I add the JComboBox is really a complex one, I preferred to use "null" layout. In JBuilder there is a XYLayout that acts the same way a "null" layout does but that makes my applet too big (and too slow to download).
Thanks anyway.