Results 1 to 6 of 6

Thread: Gridbag layout

  1. #1
    ramesh.8189 is offline Member
    Join Date
    Feb 2009
    Location
    India
    Posts
    23
    Rep Power
    0

    Default Gridbag layout

    HI i ve given a picture and I tried to do that with many layouts but i failed ultimately. Grid bag can solve it seems. Can any body send coding for constructing this structure(shown in picture)

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

    Default

    It is considered very rude to cross-post the same question in multiple fora. If you desire more folks to be motivated to help you, I would advise you not to do this.

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

    Default

    Fubarable is correct about cross-posting. We also don't provide code. Write some code, post it if you don't understand something specific, and we can try to help you.

    GridBagLayout is very powerful, and I'm sure you can use it produce your desired layout. Check out Sun's tutorial, and experiment.

    If you are not using an IDE, I suggest getting Netbeans and using the Matisse tool. It has a special function that visually displays the grid and allows you to set constraints for the components in each cell. Or, lay the components out in a spreadsheet. That can help you visualize what you are doing.

  4. #4
    ramesh.8189 is offline Member
    Join Date
    Feb 2009
    Location
    India
    Posts
    23
    Rep Power
    0

    Default

    Sir i never post without trying. i did that in net beans using Group layout(free design). but dono how to do in Grid Bag,the powerful one. Hence I requested others..
    Im not developer.. Only Java develops me..

  5. #5
    maxim is offline Member
    Join Date
    Apr 2008
    Posts
    15
    Rep Power
    0

    Default

    you can still use set the layout manager in netbeans to use gridbag instead of the default one.

    its better to hand code the layout in my opinion so you actually understand whats going on. there's a good tutorial from the official sun java tutorial on all layouts found on their website.

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

    Default

    I partially agree with Maxim. Don't blindly use a designer without having any idea of what it is doing. On the other hand, I've seen some truly awful hand-coded layout code that showed no comprehension, so hand-coding won't solve all the issues, either.

    I assume Netbeans Matisse allows you to view and add to the generated code. I know the Matisse port to Eclipse does. Here is what I suggest.

    Create a blank form in Matisse using JFrame.

    Set the JFrame layout manager to GridLayout, using the defaults.

    Add a JPanel. This will cause the JPanel to fill the content pane.

    Change the JPanel layout manager to GridBagLayout. Note that this manager has no properties.

    Add 8 labels to the JPanel.

    Right click on the GridBagLayout in the Outline and select customize.

    Play around in the designer, changing the properties of each component. Start with Grid X and Y values. Watch how setting values rearranges the labels. Make sure to use relative in one dimension while setting the other. Also, watch what happens when using relative if a "cell" is left empty to the left or above a relative component.

    Next, try Fill values.

    I don't use internal padding.

    Change the anchor values.

    Combine Fill and Weight to cause certain cells to control the dimensions of their columns and rows. By default, everything will expand to take up the whole JPanel.

    Last, set Fill to both and play with insets.
    Last edited by Steve11235; 02-24-2009 at 12:33 AM. Reason: minor change

Similar Threads

  1. Card Layout
    By Gilbee in forum NetBeans
    Replies: 3
    Last Post: 03-03-2009, 10:37 PM
  2. Gridbag layout
    By ramesh.8189 in forum New To Java
    Replies: 2
    Last Post: 02-13-2009, 07:21 PM
  3. Require Help with Layout (GridBag)
    By hemanthjava in forum AWT / Swing
    Replies: 2
    Last Post: 10-22-2008, 02:56 PM
  4. Gridbag Layout Probelm
    By hemanthjava in forum AWT / Swing
    Replies: 3
    Last Post: 12-04-2007, 06:12 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
  •