add component to JPanel

Hello everyone,

I have a JComboBox, and when i select an Option i would like to add a new component to the JPanel (just below the JComboBox). This is what i have at the moment, but i must be doing something wrong because it does nothing.

String[] choices ={"Choose option","Option 1","Option 2","Option 3","Option 4","Option 5"};

mainPanelComponent5 =new JComboBox(choices );

mainPanelComponent5.setBounds(100, 70, 150, 20);

mainPanelComponent5.addItemListener(new ItemListener(){

publicvoid itemStateChanged(ItemEvent e){

if (e.getStateChange() == ItemEvent.SELECTED){

JLabel compId =new JLabel("TEST");

compId.setBounds(210, 70, 250, 20);

mainPanel.add(compId);

}

}

});

Any help? thanks in advance

[1387 byte] By [didia] at [2007-10-2 10:26:40]
# 1
mainPanel.revalidate();
ajneoa at 2007-7-13 2:06:43 > top of Java-index,Desktop,Core GUI APIs...
# 2
> mainPanel.revalidate();Thank you, it works
didia at 2007-7-13 2:06:43 > top of Java-index,Desktop,Core GUI APIs...