• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How to adjust sizes and positions in a JPanel/JFrame

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not a good Swing programmer so I'm having frustrations on to what to do with this:



I couldn't fix the positions and the sizes... Can you help me convert this frame into something normal (normal sizes for text fields and buttons).

Here's my code:


Thank you very much in advance!
[ October 16, 2008: Message edited by: Denise Saulon ]
 
Sheriff
Posts: 22665
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A GridLayout will size all of its components equally, and you can't change that. Since in the end all your panels have the same number of components, they end up all the same size.

I'd suggest forgetting about GridLayout for this, and use a combination of other layout managers. I think that with BorderLayout and GroupLayout you should be able to get quite far.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 3 ways to make the gui layout look better .

1)GridBagLayout(Part of the standard jdk) --> GridBag Tutorial

2)MigLayout --> (Great Layout Manager ...even better than GridBagLayout but outside the jdk package)

3)Netbans Mattise GUI Builder --> Download from netbeans.org (this is the easiest way using Drag N Drop to create quick protottypes)

[ October 16, 2008: Message edited by: Pavan Kumar Srinivasan ]
[ October 16, 2008: Message edited by: Pavan Kumar Srinivasan ]
 
Rob Spoor
Sheriff
Posts: 22665
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pavan Kumar Srinivasan:
1)GridBagLayout(Part of the standard jdk) --> GridBag Tutorial


Totally Gridbag.

I'd rather shoot myself in the foot than ever use GridBagLayout.

MigLayout and JGoodies Forms' FormsLayout are also quite good but not part of the core API.
 
Pavan Kumar Srinivasan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I perfectly understand that gridbaglayout is very hard to learn ....but once you get a hang of it...you can achieve alomost any layout.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pavan Kumar Srinivasan:
There are 3 ways to make the gui layout look better .

1)GridBagLayout(Part of the standard jdk) --> GridBag Tutorial...



Go ahead and create a GridBagLayout example here and I'll at least match you with standard but non-GridBag layout code.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'd rather shoot myself in the foot than ever use GridBagLayout.



I agree with Rob. Though GBL is flexible, its a real pain in the back. MigLayout is cool. MigLayout seems cool.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic