Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simplified Question regarding ComboBox

Status
Not open for further replies.

lck092580

Programmer
Jun 19, 2002
440
CA
Sorry bout the double post but the last post i made had too much code in there. Here's a simplified one. I dunno why but I can't get the combobox to work properly. The following code DOES NOT WORK.. the pull down list doesn't even come down.
----------------------------
import java.awt.event.*;

public class Testing extends Applet
{ private JComboBox comboBox;

public void init()
{ String[] a = {"S","T","G"};
comboBox = new JComboBox(a);
//setLayout(new GridBagLayout());
setLayout(new BorderLayout());
add(comboBox, BorderLayout.NORTH);
}
}
---------------------
However.. if i changed:
add(comboBox, BorderLayout.NORTH);

To this:

add(comboBox, BorderLayout);

The list will start showing up. It seems that the JComboBox doesn't want to work if i use a gridbaglayout or gridlayout either. Could anyone shed some light into my problem? Thanks.

T
 
Are there any exceptions being thrown out in the java console?

-gc "I don't look busy because I did it right the first time."
 
Well, a long shot is that you are mixing components. Applet and Swing might not play well together. Try using JApplet instead.

-gc "I don't look busy because I did it right the first time."
 
But the thing is sun's api gives an example like this. It uses the same layout but when i apply it to my simple applet it wouldn't work.

I'm sure it's something very simple. I'm determined to figure it out. :)

T
 
And they are using Applet in conjunction with SWING components? Could you point me to the url where that example exists?

-gc "I don't look busy because I did it right the first time."
 
Did you try putting your JComboBox into a JApplet instead of an Applet. Once again, SWING components and older components from before SWING sometimes do not play very nice together.

-gc "I don't look busy because I did it right the first time."
 
Nope.. not yet but that's on my "to-do" list. U're right tho.. mixing heavy components with light ones causing too many problems. Thanks for your help.

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top