BoxLayout - can't be shared run time error

Hi!

I get this error:

Exception in thread "AWT-EventQueue-0" java.awt.AWTError: BoxLayout can't be shared.

I have a main panel, with all the UI components working fine. When I press a button I display a custom dialog. I try to set a JPanel as the dialog's content pane. Then I try to set up the BoxLayout as the layout manager for the JDialog.

But I get that awful error.

Can you please tell me why?

I enclose some code too:

JDialog sortDialog = new JDialog(frame, "Se sorteaza");

BoxLayout layout = new BoxLayout(sortDialog, BoxLayout.Y_AXIS);

sortDialog.setContentPane(new JPanel(layout));

sortDialog.pack();

sortDialog.setVisible(true);

Message was edited by:

nopceafrancisc

[772 byte] By [nopceafrancisca] at [2007-11-27 1:11:49]
# 1
Looks like you are creating your BoxLayout for the sortDialog, but then use it also on the JPanel you create afterwards.Therefore, it ends up being shared among those two containers.
TimTheEnchantora at 2007-7-11 23:47:09 > top of Java-index,Java Essentials,Java Programming...