Results 1 to 9 of 9
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default using grid layout

    I am using grid layout to design my program, and I have 4 rows, and 1 column. Each row is the same size. Is there any way to change it so that I can set the height for each one?
    Last edited by droidus; 07-03-2013 at 06:26 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,646
    Rep Power
    5

    Default Re: using grid layout

    From the tutorial.

    "A GridLayout object places components in a grid of cells. Each component takes all the available space within its cell, and each cell is exactly the same size. If the GridLayoutDemo window is resized, the GridLayout object changes the cell size so that the cells are as large as possible, given the space available to the container."

    So I would say no. Why not try out some other layout managers? Especially if you only have a single column.

    A Visual Guide to Layout Managers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: using grid layout

    If you have only one column, what would it mean to have different widths for each row?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: using grid layout

    Quote Originally Posted by jim829 View Post
    From the tutorial.

    "A GridLayout object places components in a grid of cells. Each component takes all the available space within its cell, and each cell is exactly the same size. If the GridLayoutDemo window is resized, the GridLayout object changes the cell size so that the cells are as large as possible, given the space available to the container."

    So I would say no. Why not try out some other layout managers? Especially if you only have a single column.

    A Visual Guide to Layout Managers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)

    Regards,
    Jim
    "The BoxLayout class puts components in a single row or column. It respects the components' requested maximum sizes and also lets you align components."

    would box layout work best for my scenario?

  5. #5
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: using grid layout

    Quote Originally Posted by DarrylBurke View Post
    If you have only one column, what would it mean to have different widths for each row?

    db
    *height sorry

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,646
    Rep Power
    5

    Default Re: using grid layout

    I thought the OP meant different widths for each row such that the width of a cell in a given row is different than the width of the cells in any other row. This could also apply to a single column. Of course, now that the OP edited the original post, my reply makes no sense (assuming it did before).

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  7. #7
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    265
    Rep Power
    2

    Default Re: using grid layout


  8. #8
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: using grid layout

    I think you are right, in that the panels will fill the width of the space it is given, it seems.
    it says in the doc that it is complex. i might just try and do netbeans if I can't fix it as is, or in a simple way.

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: using grid layout

    Quote Originally Posted by droidus View Post
    *height sorry
    Use a Box.createVerticalBox()

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Grid Layout change layout alignment of control s
    By rellicott in forum SWT / JFace
    Replies: 1
    Last Post: 02-13-2012, 05:11 PM
  2. Image into Grid layout
    By Jaxn77 in forum AWT / Swing
    Replies: 6
    Last Post: 02-10-2011, 03:02 PM
  3. Image into Grid layout
    By Jaxn77 in forum Java Applets
    Replies: 1
    Last Post: 02-10-2011, 03:18 AM
  4. Redrawing the grid bag layout
    By preethidv in forum AWT / Swing
    Replies: 1
    Last Post: 06-22-2010, 05:23 AM
  5. Help with Grid Layout
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08:03 PM

Posting Permissions

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