> In a JPanel (in a JInternalFrame) I use a JComponent.
> At startup a JLabel is set to this JComponent (JComponent theJComponent =
> theJLabel;) and the JLabel is properly shown.
I assume that what you do after this is to add the JLabel to the JPanel.
> When a user performs a certain action (like pressing a button) I want to
> display a JComboBox instead of this JLabel (i.e. in the same place).
> I seem to be missing something, because I can't get it to work. After
> setting theJComponent = theJComboBox,
What do you want to achieve by this? The only thing you achieve is to
make the reference that once pointed to the JLabel that is displayed on
the JPanel to point to another Component, i.e. the JComboBox. You
haven't done anything with the components in the JPanel.
You need to remove the JLabel and add a JComboBox in the same spot. I
don't know what the rest of your layout looks like, but this should be
no problem using a GridBagLayout or a CardLayout.
Erik.
Andreas - 28 Sep 2003 11:47 GMT
> What do you want to achieve by this?
> You haven't done anything with the components in the JPanel.
Of course you are correct, and now it works like it should.
This was embarrasingly stupid, and I guess I was just having a bad brain
day (as opposed to bad hair day) or something.
I'm gonna go and hide now.
Thanks a lot Erik. Much appreciated.
/Andreas