Solved

Using Swing's JComboBox...

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

919 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

18 Experts available now in Live!

Get 1:1 Help Now