⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e422. determining when a preference node is added or removed.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
A NodeChangeEvent is fired when a preference node gets a new child node or loses a child node. This event is only guaranteed to fire if the listener and modifier are in the same application. 
See also e421 Listening for Changes to Preference Values in a Preference Node. 

    // Retrieve the user preference node for the package java.lang
    Preferences prefs = Preferences.userNodeForPackage(String.class);
    
    // Register the listener
    prefs.addNodeChangeListener(new NodeChangeListener() {
        public void childAdded(NodeChangeEvent evt) {
            // Get the node with the new child
            Preferences parent = evt.getParent();
    
            // Get the newly added child
            Preferences child = evt.getChild();
        }
        public void childRemoved(NodeChangeEvent evt) {
            // Get the node whose child was removed
            Preferences parent = evt.getParent();
    
            // Get the removed child
            Preferences child = evt.getChild();
        }
    });
    
    // Add a child preference node
    Preferences child = prefs.node("new node");
    
    try {
        // Remove the child preference node
        child.removeNode();
    
        // Remove current node; this does not fire a NodeChangeEvent
        prefs.removeNode();
    } catch (BackingStoreException e) {
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -