aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes simple GridBagLayout question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "simple GridBagLayout question" Watch "simple GridBagLayout question" New topic
Author

simple GridBagLayout question

Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
Ok, I thought I understood GBL, but obviously I dont! -below is a simple piece of code which I thought would give me a blue panel, 200*700 anchored to the north of the frame, which is nearly fullscreen size.
Can anyone tell me why all I get is a tiny blue square in the middle of the screen?!!
Thanks,

Eoin.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
change
0.0, 0.0, // weightx, weighty

to
0.5, 0.5, // weightx, weighty

and see what happens
Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
Thanks Michael,
That dosnt make any difference. Im really confused! -Ive dropped GBL for now though, I can get sufficiently good results using null layout, so Im going to run with that, seems easier!!
Thanks for your help though.

E
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> That dosnt make any difference.

it does with me - winXP, java 1.5.0_05

it goes from a small square 10x10?, to fill the contentPane 1010x700

note:
myPanel.setSize(200,700);
won't work when subject to a layout manager

> I can get sufficiently good results using null layout,
the 'gotchas' will come back and bite you, but, so be it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: simple GridBagLayout question