Solved

Using Swing's JComboBox...

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
simple java question 3 56
servlet example 11 40
Custom Java Application connects to database: Which one of the 20? 4 29
jsp login check 12 32
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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

821 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