Results 1 to 5 of 5
  1. #1
    mainy is offline Member
    Join Date
    Feb 2009
    Posts
    38
    Rep Power
    0

    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:

    Java 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

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    BoxLayout seems to be intended to allow you to put boxes in boxes. Try that.

  3. #3
    mainy is offline Member
    Join Date
    Feb 2009
    Posts
    38
    Rep Power
    0

    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.

  4. #4
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    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.

  5. #5
    mainy is offline Member
    Join Date
    Feb 2009
    Posts
    38
    Rep Power
    0

    Default

    Awesome, thank you Steve.

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



    Thanks again

Similar Threads

  1. BorderLayout Demo
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:51 PM
  2. Area Add
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:07 AM
  3. Area Intersect
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:07 AM
  4. Print Area
    By Riftwalker in forum Advanced Java
    Replies: 0
    Last Post: 11-28-2007, 08:28 PM
  5. Help with BorderLayout
    By lenny in forum AWT / Swing
    Replies: 1
    Last Post: 07-31-2007, 08:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •