• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComponent Change Size?

 
Warren Bell
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New to Swing AWT. How do you change the size of a JComponent many different times? Also, when does getPrefferedSize() get called?
I am able to change the size of a JComponent once initially but I am unable to change the size again. I have the JComponent in a Border layout center position.
Any help will be appreciated.
Thanks,
Warren Bell
warren@netricks.net
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can internally change the size of a component, but that doesn't do any kind of notification to repaint or re-layout the component. After changing the size, call invalidate(), validate(), and/or repaint().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic