Solved

Using Swing's JComboBox...

Posted on 1998-04-06
3
232 Views
Last Modified: 2008-03-06
I am having trouble with the JComboBox from Swing.  I have a combo box on one of my panels.  I have added a few items to the combo box.  When I run the app, and try to select an item from the combo box, the popup list of items does not appear.  Why is this, and how can I fix it?
0
Comment
Question by:stepma
3 Comments
 
LVL 5

Expert Comment

by:fontaine
ID: 1233945
Maybe are you using both AWT and Swing components. This is not recommended. If you are adding the JComboBox to a Panel, try using a JPanel instead. If this is not the problem, it is difficult to make a diagnosis without taking a look at the code...
0
 

Author Comment

by:stepma
ID: 1233946
I am using a JPanel...Here is the code:

val_sph = new JComboBox(items);
            val_sph.setSelectedIndex(0);
            val_sph.setLightWeightPopupEnabled(false);
            val_sph.setEditable(false);
            add(val_sph);

I have gotten it to work by adding setLightWeightPopupEnabled(false);
Why is this?
0
 
LVL 1

Accepted Solution

by:
mnelson051997 earned 50 total points
ID: 1233947
Is your JComboBox at the bottom of the panel?  If so, making the
popup heavy will allow it to display outside the panel.  This would
explain why it shows up when you use setLightWeightPopupEnabled(false).
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question