This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Geting Panel Size from Container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Geting Panel Size from Container" Watch "Geting Panel Size from Container" New topic
Author

Geting Panel Size from Container

Tim Berett
Ranch Hand

Joined: Jun 14, 2002
Posts: 35
Hi,

I have a JPanel in a JFrame. In additional, I have some graphical charts in the JPanel. When I resize my JFrame, I want my graphical charts to scale accordingly. How do I implement a resize container listener in my JPanel or graphical chart?

Tim
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
You should be able to detect a resize in the paint()(or whatever method for Swing) method and do the rescaling there. Get the component's size and paint() it full.
Put some println(getSize()) in paint() to see how the size changes with resizing.
 
wood burning stoves
 
subject: Geting Panel Size from Container
 
Similar Threads
How to stop graphics from disappearing?
resize ?
Resizing Widgets in Frame
JScrollPane JViewport question
Problem with JTree inside JScrollPane inside JPanel