Example usage for java.util.prefs NodeChangeEvent getParent

List of usage examples for java.util.prefs NodeChangeEvent getParent

Introduction

In this page you can find the example usage for java.util.prefs NodeChangeEvent getParent.

Prototype

public Preferences getParent() 

Source Link

Document

Returns the parent of the node that was added or removed.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Preferences prefs = Preferences.userNodeForPackage(String.class);

    prefs.addNodeChangeListener(new NodeChangeListener() {
        public void childAdded(NodeChangeEvent evt) {
            Preferences parent = evt.getParent();
            Preferences child = evt.getChild();
        }//from  w  w w .  j a  v a2s .  co  m

        public void childRemoved(NodeChangeEvent evt) {
            Preferences parent = evt.getParent();
            Preferences child = evt.getChild();
        }
    });
    Preferences child = prefs.node("new node");
    child.removeNode();
    prefs.removeNode();
}