aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GridLayout Vertical gap error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GridLayout Vertical gap error" Watch "GridLayout Vertical gap error" New topic
Author

GridLayout Vertical gap error

Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

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.



Are you better than me? Then please show me my mistakes..
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

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:


    luck, db
    There are no new questions, but there may be new answers.
    Yohan Weerasinghe
    Ranch Hand

    Joined: Oct 07, 2010
    Posts: 499

    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

    Joined: May 03, 2008
    Posts: 4658
        
        5

    The first row should be lot smaller than the second row

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

    Yohan Weerasinghe
    Ranch Hand

    Joined: Oct 07, 2010
    Posts: 499

    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.
     
    Don't get me started about those stupid light bulbs.
     
    subject: GridLayout Vertical gap error