This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel" Watch "JPanel" New topic
Author

JPanel

ramesh kancherla
Ranch Hand

Joined: May 01, 2008
Posts: 124
How can I change Jpanel Resize
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41597
    
  55
Check out the setMinimumSize, setPreferredSize and setMaximumSize methods.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38456
    
  23
You don't. There isn't actually a resize() method in JPanel, but there is in Component, but it is deprecated. Read the details in the API.

If you do alter the size of a Component, you may have to call validate() and pack() on its enclosing Container as well.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

It doesn't guarantee the panel will get that size at all. It's all up to the layout manager of the enclosing container.

pack() is only part of Window and its subclasses, as well as JInternalFrame and JPopupMenu.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPanel