| Author |
GridLayout Vertical gap error
|
Yohan Weerasinghe
Ranch Hand
Joined: Oct 07, 2010
Posts: 485
|
|
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: 4165
|
|
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: 485
|
|
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: 4165
|
|
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: 485
|
|
OK..Thanks.......I really appreciate your help. Marking this thread as solved.
|
 |
 |
|
|
subject: GridLayout Vertical gap error
|
|
|