• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame

 
raja syamala
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a class that extends JFrame and JPanel, JTabbedPane, JButtons etc.. are added to it. I am using
classname.setSize(500,500).
But when I maximize the window manually or resize the window the size of the contents in the frame are changing. Is there a way to set the size of the frame and its components to be constant all the time. I tried to use the same method on the components as well. But the problem still persists.
Tried using pack(). But didn't work the way I want it.
Please let me know if there is any way to set the fixed size.
Thanks in advance.
 
G Gordan
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you just set layout of content panel to null.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you follow the above hint, be sure to set the location and size of all your components using setBounds( x, y, w, h )...

-Nate
 
K Venugopal
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using setResizable(false). This will disable resizing of your Frame.
hope this suffices.
------------------
 
Daniel Searson
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd also reccommend using setResizable(false) as using no layout manager can get messy.
-Daniel
 
jaganbala
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U will have to use GridBagLayout and set the fill factor for all the components as None.Then the components will retain its original size even if the screen was maximised.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic