• Post Reply Bookmark Topic Watch Topic
  • New Topic

Component size  RSS feed

 
keith meyer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

When I try to make a Swing app and use the GridLayout my JTextFields are huge. Is there a way I can control this, I've tried using spacing but that hasn't helped. Any help is appreciated. Thanks.

Keith
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Try the setMaximumSize and setPreferredSize methods. Setting those values influences component resizing done by the layout manager.
 
keith meyer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks on both counts :-) Couldn't find a clear answer on that question.
 
Parth Bhatt
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the setBorder(new EmptyBorder(10,10,10,10)) on the text field, with appropreate values... U'll hav to import javax.swing.border.EmptyBorder; for this...

This is definately not the best solution as when the window is resized the textfield size still increases, the output is a lil less awkward, though...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!