aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JTextField in GridLayout format Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTextField in GridLayout format" Watch "JTextField in GridLayout format" New topic
Author

JTextField in GridLayout format

K. Tsang
Ranch Hand

Joined: Sep 13, 2007
Posts: 1219

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JTextField in GridLayout format
 
Similar Threads
JTextField preferred size
Resizing
Box Layout doubts
Jar...
GridBagLayout Question: Irregular Spacing