JComboBox don't work here

I have a code like below, it complile fine, but the JComboBox don't work. If I resize the GUI manaually to very small height, these JComboBox start work. I don't understand why this happens. Any idea is high appreciated. Please email me at fu@bnl.gov. Many thanks.

import javax.swing.*;

import java.awt.HeadlessException;

import java.awt.*;

public class testComboBox extends JFrame {

String[] _tmp={"XY PLOT", "AREA", "PIE", "BAR", "CANDLE"};

JComboBox _cb1= new JComboBox(_tmp);

String[] _tmp1={"Top", "Bottom"};

JComboBox _cb2=new JComboBox(_tmp1);

String[] _tmp2={"SOUTH","EAST"};

JComboBox _cb3=new JComboBox(_tmp2);

public testComboBox() throws HeadlessException {

this.setSize(new Dimension(200, 180));

JPanel _jp=new JPanel();

_jp.setSize(new Dimension(200, 160));

_jp.setLayout(new GridBagLayout());

GridBagConstraints _myBag= new GridBagConstraints();

_myBag.insets=new Insets(2,2,2,2);

_myBag.weightx=1.0;

_myBag.weighty=1.0;

_myBag.gridx=0;

_myBag.gridy=0;

_jp.add(_cb1, _myBag);

_myBag.gridx=0;

_myBag.gridy=1;

_jp.add(_cb2, _myBag);

_myBag.gridx=0;

_myBag.gridy=2;

_jp.add(_cb3, _myBag);

this.getRootPane().setLayout(new GridBagLayout());

GridBagConstraints _myBag1= new GridBagConstraints();

_myBag1.insets=new Insets(2,2,2,2);

_myBag1.weightx=1.0;

_myBag1.weighty=1.0;

_myBag1.gridx=0;

_myBag1.gridy=0;

this.getRootPane().add(_jp, _myBag1);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

}

public static void main(String[] args) throws HeadlessException {

testComboBox testComboBox1 = new testComboBox();

testComboBox1.show();

}

}

[1941 byte] By [wfu168] at [2007-9-30 14:28:58]
# 1
try adding testComboBox1.pack() before the show()honestly, you'll get a better answer posing a link to this in the swing forum (do not X-post, just put in a link to this)
EvilEdna at 2007-7-5 13:42:24 > top of Java-index,Administration Tools,Sun Connection...