This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread 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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel" Watch "JPanel" New topic


ramesh kancherla
Ranch Hand

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

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

Ping & DNS - updated with new look and Ping home screen widget
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36575
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

Joined: Oct 27, 2005
Posts: 19552

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: JPanel
Similar Threads
obtaining the component tree for a particular JPanel
WA #2 ..... word association
remove method
Poping up a JPanel in JApplet
What to draw on?