Results 1 to 3 of 3
  1. #1
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default LayoutManager Best Choice

    I'm not all that familiar with the different layout managers right now so I'm hoping someone can point out the best manager for my situation:

    I have 3 areas that will be on the form:

    -- JEditorPane (1)
    -- JPanel (2)
    -- JLabel (3)

    They are arranged as follows:

    -----------------------
    |###|############|
    |###|############|
    | (2) |####(1)######|
    |###|############|
    |###|############|
    |____|_______________|
    |________(3)_________|

    The JLabel is at the bottom of the form and is 20 pixels high and as wide as the form.

    The JPanel is 50 pixels wide and as tall as the form, minus the 20 pixels for the JLabel.

    The JEditorPane is as wide as the form allows (but of course right next to the JPanel) and as wide as the form will allow.

    Right now I just wrote a component listener that detects resizing and does everything for me but if you have ever quickly resized a form that is using this method, you get a nasty black area before the items resize themselves correctly.

    If you know of a layout manager that will allow me to do all of this or a way to remove the nasty black area when using a component listener, I would appreciate your response.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You usually use a combination of layout managers, but in your example above, mostly BorderLayout. But why guess at what they do? The tutorials show you visually what they do. Please have a look.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    For instance, this simple GUI has a JPanel that uses GridBagLayout for the JLabels and JTextFields in the upper left corner, a JPanel that uses FlowLayout for the buttons below this, a JPanel that uses BoxLayout to hold the GridBagLayout JPanel and the FlowLayout JButton panel, and a JPanel that uses BorderLayout to hold the BoxLayout JPanel on the left and a JEditPane in the Center section.
    Attached Thumbnails Attached Thumbnails LayoutManager Best Choice-savejpggui1.jpg  

Similar Threads

  1. Changing buttonsizes in layoutmanager
    By frederic202 in forum AWT / Swing
    Replies: 2
    Last Post: 03-23-2010, 07:08 PM
  2. What layoutmanager is suitable for forms.
    By Somelauw in forum AWT / Swing
    Replies: 9
    Last Post: 12-05-2009, 02:04 PM
  3. Syntax for choice box(combo box)
    By NickkicN in forum New To Java
    Replies: 2
    Last Post: 08-14-2008, 11:26 PM
  4. Need help with T/F and Multiple Choice
    By sayso36 in forum Advanced Java
    Replies: 0
    Last Post: 03-12-2008, 05:39 PM
  5. Using java.awt.Choice
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-02-2008, 07:33 PM

Tags for this Thread

Posting Permissions

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