Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JFrame.updateUI() ??

800449Apr 7 2007 — edited Apr 23 2007
Hi!

I'd like to update all of the JComponents in a JFrame. Since JFrame (java 1.5) doesn't take the updateUI() method, how do it do it without hard coding each item?

I've tried Frame.getComponents(), then cast back to JComponents, but it did absolutely nothing.

I've also notice many Java applications require a restart after L&F has changed, which seems unnecessary.
/* This is really ugly, but couldn't find a better method */
	private void updateUI() {
		JComponent all[] = {oneList,
				onePanel,
				twoPanel,
				oneScroll,
				oneScroll.getHorizontalScrollBar(),
				oneScroll.getVerticalScrollBar(),
				twoScroll,
				twoScroll.getHorizontalScrollBar(),
				twoScroll.getVerticalScrollBar(),
				oneTree};
		for (JComponent j : all) {
			j.updateUI();
		}
		
		for (JComponent j : oneButtons) {
			j.updateUI();
		}
	}
-Tres / FBL
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2007
Added on Apr 7 2007
13 comments
434 views