Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GridLayout Vertical gap error

 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Here I am trying to adjust the Vertical gap of the GridLayout because the gap between the components are too much for me. But it seems like that code I used is not working. please help me. Here is my code.

 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yohan Weerasinghe wrote:But it seems like that code I used is not working.


In what way is is 'not working'?

Some notes on your posted code:
  • By convention, Java class names start with an uppercase letter.
  • JPanel has a constructer that accepts a layout.
  • A JFrame's getContentPane() returns a Container. There is no need to cast to JPanel to add components.
  • The content pane of a JFrame has a BorderLayout by default.
  • There is no need to validate a GUI if all sizing etc. operations are carried out before it is made visible.


  • Applying these, and getting rid of unnecessary blank likes reduces your code to this:
     
    Yohan Weerasinghe
    Ranch Hand
    Posts: 507
    Java Netbeans IDE Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I really appreciate those advice, they are great! Please guide me to the success like that. I am open to any advice, comment from anyone who has more knowledge than me.

    In what way is is 'not working'?


    The vertical gap. The vertical gap is too much. What I want is this. The first row should be lot smaller than the second row, because second row is the place I am gonna add details. I tried to adjust the gap using "setVgap(1)" but I didn't get the expected result. Please help
     
    Darryl Burke
    Bartender
    Posts: 5148
    11
    Java Netbeans IDE Opera
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The first row should be lot smaller than the second row

    Then don't use a GridLayout. Choose another layout.

     
    Yohan Weerasinghe
    Ranch Hand
    Posts: 507
    Java Netbeans IDE Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Darryl Burke wrote:
    The first row should be lot smaller than the second row

    Then don't use a GridLayout. Choose another layout.



    OK..Thanks.......I really appreciate your help. Marking this thread as solved.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic