![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e872. Setting a UI Default Value That Is Created at Every FetchTheUIDefaults table supports values that are created every time
they are fetched. Such values are called active values.
For values that are created only once, see e871 Setting a UI Default Value That Is Created When Fetched. This example declares an active value (a // Create an active value Object activeValue = new UIDefaults.ActiveValue() { // This method is called every time the value is fetched. // If this method can be called no more than once, it must be synchronized. public Object createValue(UIDefaults table) { return new Date(); } }; // Add the active value to the UI defaults table UIManager.put("key", activeValue); // Fetch the value twice; this causes the value to be created twice Date d1 = (Date)UIManager.get("key"); Date d2 = (Date)UIManager.get("key"); boolean b = d1.equals(d2); // false
e871. Setting a UI Default Value That Is Created When Fetched © 2002 Addison-Wesley. |