Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 BoxLayout error
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aziz




PostPosted: 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
Sponsor
sponsor
HellblazerX




PostPosted: 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




PostPosted: 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.

I was using

code:
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




PostPosted: 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




PostPosted: 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));


You can definitely file a bug-report on that. Smile
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: