This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JComponent Change Size? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComponent Change Size?" Watch "JComponent Change Size?" New topic

JComponent Change Size?

Warren Bell
Ranch Hand

Joined: Dec 20, 2000
Posts: 56
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.
Warren Bell
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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().

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Don't get me started about those stupid light bulbs.
subject: JComponent Change Size?
Similar Threads
customized jcomponent icon is painting itslef on top of menu
My favorites cars
setBackground(); isn't working
Changing Column Header height of JTable
Jpanels and Jscrollpanels