• Post Reply Bookmark Topic Watch Topic
  • New Topic

Size of TextField increases wrt window size

 
RaviSingh Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Added text field in a panel(Using Gridlayout) and that panel to a frame.
The size of textfield get increases as window size increase.
Wanted some combination of layout to fix this bug.
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by RaviSingh Kumar:
Added text field in a panel(Using Gridlayout) and that panel to a frame.
The size of textfield get increases as window size increase.
Wanted some combination of layout to fix this bug.


Well that's how GridLayout works.

If you consider it a bug then either use an intervening panel or use a different layout completely.

By intervening panel I mean replace
add(yourTextField);
with
JPanel flowPanel = new JPanel();
flowPanel.add(yourTextField);
add(flowPanel);
// yourTextField.setColumns(width) may also be necessary, depending
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!