• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

why JTextField gets expanded when i maximize the JFrame window

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ???
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic