• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextField in GridLayout format

 
K. Tsang
Bartender
Posts: 3457
14
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I have a question. If I have a JTextField add to a JPanel, the height of it is the size of the mouse cursor. When I set the JPanel layout manager to use GridLayout, the JTextField fills up the grid cell height and width.

If I set the field's maximumSize() it doesn't seem to change a thing. Any idea to change the size without using GridBagLayout.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GridLayout doesn't really respect the component's preferredSize (well it will if the visual portion of the grid is filled with components, but otherwise it doesn't). You may need to place your gridlayout in a FlowLayout panel or somesuch to allow the gridlayout panel to shrink if it's not filled.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic