📄 e872. setting a ui default value that is created at every fetch.txt
字号:
The UIDefaults 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 Date) that is created every time it is fetched.
// 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -