Solved

Using Swing's JComboBox...

Posted on 1998-04-06
3
228 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now