Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: arranging components in a vertical manner in a jpanel?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default arranging components in a vertical manner in a jpanel?

    Hi guys, I'm just starting in java... or coming back to using it again... I'm not that good so I was wondering after reading on my old java book, how to arrange components such as labels and buttons in a panel in a vertical position, much like a webpage link panel on the left side where the user chooses which page he wants to go to... the default layout of a jpanel is a flowlayout I think and all the components I add to it just automatically arranges itself horizontally which is really far from what I want to do... Hope any help would be ok... it would be easier if it was html where I just add a <br> in order to skip a line and then just add each separate link... is there some sort of absolute positioning for components in a panel or contentpane where I can use to store jlabels/jbuttons so I can arrange the components in a way that can be more user friendly... thanks again...


  2. #2
    Junior Member Krumpir's Avatar
    Join Date
    Jul 2012
    Location
    Cape Town, South Africa
    Posts
    9
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: arranging components in a vertical manner in a jpanel?

    Oracle has a Visual Guide to Layout Managers that you might find useful for choosing which layout manager to use.

    Another approach to consider is to create a JTabbedPane and align all the tabs on the left.
    Check out my site -> tssolutions.net16.net

  3. #3
    Member
    Join Date
    Jul 2012
    Posts
    83
    My Mood
    Cynical
    Thanks
    3
    Thanked 9 Times in 9 Posts

    Default Re: arranging components in a vertical manner in a jpanel?

    Consider using nested JPanels with the outer JPanel using BorderLayout. It holds a JPanel on its WEST side that can use BoxLayout, and then it holds another JPanel in the BorderLayout.CENTER position that uses a CardLayout to swap views, the view choice is based on whatever was clicked on the WEST JPanel.

Similar Threads

  1. [SOLVED] Pesky <JPanel>.getWidth() and <JPanel>.getHeight() Methods...
    By snowguy13 in forum AWT / Java Swing
    Replies: 1
    Last Post: December 31st, 2011, 03:35 PM
  2. [Help] Arranging Objects please help
    By JoelE21101 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 20th, 2011, 11:37 PM
  3. 1 vertical scroll bar fro 2 jtextareas
    By fortune2k in forum AWT / Java Swing
    Replies: 8
    Last Post: March 4th, 2011, 02:04 PM
  4. Arranging words in a sentence in alphabatical order.
    By J2000 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 24th, 2011, 10:04 AM
  5. count components inside a JPanel
    By dewboy3d in forum AWT / Java Swing
    Replies: 1
    Last Post: August 2nd, 2009, 03:17 PM