• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Geting Panel Size from Container

 
Tim Berett
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 707
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic