Skip to main content

A bug with JXCollapsiblePane and BoxLayout?

2 replies [Last post]
i30817
Offline
Joined: 2006-05-02
Points: 0

It seems that JXCollapsiblePane starts with a kind of box layout, but i didn't know that and tried to set it myself:

this gives an error:
BoxLayout lay = new BoxLayout(paneToCollapse, BoxLayout.X_AXIS);
paneToCollapse.setLayout(lay);
paneToCollapse.add(Box.createVerticalStrut(300));
paneToCollapse.add(new JButton("hello"));

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

This does not (and seems to be equivalent):
paneToCollapse.add(Box.createVerticalStrut(300));
paneToCollapse.add(new JButton("hello"));

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rbair
Offline
Joined: 2003-07-08
Points: 0

It uses a VerticalLayout.

i30817
Offline
Joined: 2006-05-02
Points: 0

So what is that error anyway? Goggleing it it seems it should only occur if BoxLayout was used in two different components, and unless the setLayout method in JXCollapsiblePane sets the layout for multiple internal components i don't really see how it could occur.