Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why JTextField gets expanded when i maximize the JFrame window

 
great veera
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
great veera
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vinod,nathan
Thanks for helping me out,
Nathan my name is not great my name is the second part of this username Veera
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic