The Artima Developer Community
Sponsored Link

Java Buzz Forum
Desktop Java Live: UIDefaults Confusion

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Delap

Posts: 1154
Nickname: scottdelap
Registered: Sep, 2004

Client / Server application developer.
Desktop Java Live: UIDefaults Confusion Posted: Jan 6, 2005 5:09 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Scott Delap.
Original Post: Desktop Java Live: UIDefaults Confusion
Feed Title: ClientJava.com
Feed URL: http://www.clientjava.com/archives/wireless_mobile.rdf
Feed Description: Client/Desktop Related Java Development
Latest Java Buzz Posts
Latest Java Buzz Posts by Scott Delap
Latest Posts From ClientJava.com

Advertisement

I ran across some confusing functionality with UIDefaults the other night. Let's see if anyone agrees with me...

The UIDefaults object associated with look and feels in Swing extends Hashtable and holds mappings for look and feel related properties. You'll find things like icons, colors. fonts, etc. Adding to this complexity is the fact that there are actually three sets of UIDefaults user, look and feel, and system. Because of this when you call

    UIManager.getDefaults()
it says you are getting a plain UIDefaults object but you are not. Instead you get this strange MultiUIDefaults object that extends UIDefaults. It basically wraps the three sets of objects and looks through them all on a get request for a property starting with the user set. All of this is well and good. The MultiUIDefaults object provides custom implementations of standard methods like get(), size(), clear(), and remove(). Now on to my strange fact for the day. I'm writing a UIDefaults viewer for the book and wanted to iterate over all the properties. So logically I call

    uiDefaults.keySet().iterator()

However, strangely my table only has about 5 properties in it. I knew that wasn't right. Turns out that MultiUIDefaults implements keys() which returns and Enumeration but not keySet(). Without looking at the source I would have never known this. When you extend a class should you not try to keep the meaning/spirit of its methods consistent with the parent? I really don't think I'm asking too much here.

Read: Desktop Java Live: UIDefaults Confusion

Topic: Futures and Concurrent Programming (Part 1) Previous Topic   Next Topic Topic: [Dec 27, 2004 17:33 PST] 4 Links

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use