Posted: Wed Jul 26, 2006 7:16 am Post subject: 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.
Sponsor Sponsor
HellblazerX
Posted: Wed Jul 26, 2006 7:33 am Post subject: (No subject)
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
Posted: Wed Jul 26, 2006 8:31 am Post subject: (No subject)
Thanks, that explain the how, and would explain the why if I didn't figure it out myself.
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
Posted: Wed Jul 26, 2006 8:35 am Post subject: (No subject)
Wtf, no, hold on, why is this giving me the can't be shared error?
code:
panel = new JPanel(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
rizzix
Posted: Wed Jul 26, 2006 10:03 am Post subject: (No subject)
Aziz wrote:
Wtf, no, hold on, why is this giving me the can't be shared error?
code:
panel = new JPanel(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
Umm do this:
code:
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));