
-----------------------------------
Aziz
Wed Jul 26, 2006 7:16 am

BoxLayout error
-----------------------------------
Why am I getting "BoxLayout cannot be shared" errors? Wtf does this mean? I've switch my layouts around (looks better now anyways), but I've never had this problem before and I just want to know what it means.

-----------------------------------
HellblazerX
Wed Jul 26, 2006 7:33 am


-----------------------------------
It means that the BoxLayout can only be used with the container it was designed to be used with.  See, when you create a new BoxLayout, you have to pass in a container object.  Only that container can be used with the BoxLayout.  You can't have another container use that BoxLayout.  You'll have to create a new one.

-----------------------------------
Aziz
Wed Jul 26, 2006 8:31 am


-----------------------------------
Thanks, that explain the how, and would explain the why if I didn't figure it out myself.

I was using

setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

In a JFrame or JDialog, while I should've been using getContentPane() for the  Container, correct? Well, it solved my problem (using it for a custom dialog)

-----------------------------------
Aziz
Wed Jul 26, 2006 8:35 am


-----------------------------------
Wtf, no, hold on, why is this giving me the can't be shared error?

panel = new JPanel(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

-----------------------------------
rizzix
Wed Jul 26, 2006 10:03 am


-----------------------------------
Wtf, no, hold on, why is this giving me the can't be shared error?

panel = new JPanel(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

Umm do this:panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

You can definitely file a bug-report on that. :)
