Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-16-2009, 03:01 PM
Member
 
Join Date: Feb 2009
Posts: 38
Rep Power: 0
mainy is on a distinguished road
Default [SOLVED] Possible to have two BoxLayout in same area of BorderLayout?
Hello

This is another problem I am having with the GUI of my program. Basically, I have a class called MainInterface, it is a JFrame built from BoxLayout components inside a BorderLayout.

Forexample:

Code:
JPanel top = new JPanel();
top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS));

....

Container contentPane = getContentPane();
contentPane.add(top, BorderLayout.PAGE_START);
As you can see, the buttons ect inside Jpanel top are laid out along a Y_AXIS. Is it possible to have two BoxLayouts, one Y_AXIS the other X_AXIS both within the PAGE_START of the BorderLayout?

Thank you

Last edited by mainy; 02-16-2009 at 04:16 PM. Reason: Grammar mistakes
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 02-16-2009, 04:23 PM
Steve11235's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 972
Rep Power: 2
Steve11235 is on a distinguished road
Default
BoxLayout seems to be intended to allow you to put boxes in boxes. Try that.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-16-2009, 04:57 PM
Member
 
Join Date: Feb 2009
Posts: 38
Rep Power: 0
mainy is on a distinguished road
Default
Hi Steve.

Thank you for your input. I have checked the Java swing references and I believe you are right. I got a test now but once I get back I'll give it a go. If I come across any problems Ill post them up.

Thank you

Last edited by mainy; 02-16-2009 at 05:01 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-16-2009, 05:17 PM
Steve11235's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 972
Rep Power: 2
Steve11235 is on a distinguished road
Default
All container-type components have an add() method.

Each time you create a component, you should assign it to a instance field so you can keep track of it.

Add the JPanel to the content pane.

Add the first box to the JPanel

Add two more boxes to the first box.

Add components to the boxes.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 02-16-2009, 10:52 PM
Member
 
Join Date: Feb 2009
Posts: 38
Rep Power: 0
mainy is on a distinguished road
Default
Awesome, thank you Steve.

I have it all working, you are a genius ^^



Thanks again
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
BorderLayout Demo Java Tip SWT 0 07-11-2008 05:51 PM
Area Add Java Tip java.awt 0 06-23-2008 12:07 AM
Area Intersect Java Tip java.awt 0 06-23-2008 12:07 AM
Print Area Riftwalker Advanced Java 0 11-28-2007 08:28 PM
Help with BorderLayout lenny AWT / Swing 1 07-31-2007 08:26 AM


All times are GMT +2. The time now is 03:08 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org