File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes why  JTextField gets expanded when i maximize the JFrame window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "why  JTextField gets expanded when i maximize the JFrame window" Watch "why  JTextField gets expanded when i maximize the JFrame window" New topic
Author

why JTextField gets expanded when i maximize the JFrame window

great veera
Greenhorn

Joined: May 14, 2001
Posts: 24
Hi all
Can anyone tell how to nullify this effect of JTextField or any other component getting maximized when i maximize the JFrame window.
TIA
GV
vinod ac
Greenhorn

Joined: Jul 08, 2001
Posts: 9
Hi Gr8
Try using setBounds() method with null layout
Container c = getContentPane();
c.setLayout(null);
(JTextField object).setBounds(5,5,100,25);
c.add(JtextField Object)
k ? got it ???
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Or, add it to a JPanel, and then add the JPanel to the frame...

frames have a default BorderLayout layout manager, and Panels have a default FlowLayout. BorderLayout resizes the middle part of the layout, FlowLayout just sticks on a component with it's preferred size.

If you purposefully set the layout manager to null as listed above you can use setBounds() to specify the size and location off all your GUI elements. However, they will not be resized or moved if the window changes size.

You can read more about layout managers here.

-Nate

P.S. - Is your name really Great?
[This message has been edited by Nathan Pruett (edited July 17, 2001).]


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
great veera
Greenhorn

Joined: May 14, 2001
Posts: 24
Hi vinod,nathan
Thanks for helping me out,
Nathan my name is not great my name is the second part of this username Veera
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why JTextField gets expanded when i maximize the JFrame window