import java.beans.*; import org.openide.TopManager; import org.openide.ErrorManager; import org.openide.actions.ToolsAction; import org.openide.actions.PropertiesAction; import org.openide.nodes.*; import org.openide.util.HelpCtx; import org.openide.util.actions.SystemAction; public class InPlaceTestNode extends AbstractNode { private String myValue = "test"; public InPlaceTestNode() { super(Children.LEAF); setDefaultAction(SystemAction.get(PropertiesAction.class)); setName("preferablyUniqueNameForThisNodeAmongSiblings"); setDisplayName("test node"); } // Create the popup menu: protected SystemAction[] createActions() { return new SystemAction[] { SystemAction.get(ToolsAction.class), null, SystemAction.get(PropertiesAction.class), }; } public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } // Create a property sheet: protected Sheet createSheet() { Sheet sheet = super.createSheet(); // Make sure there is a "Properties" set: Sheet.Set props = sheet.get(Sheet.PROPERTIES); // get by name, not display name if (props == null) { props = Sheet.createPropertiesSet(); sheet.put(props); } props.put(new TestProp("TEST", true)); return sheet; } private class TestProp extends PropertySupport { public TestProp(String name, boolean isWriteable) { super(name, String.class, name, "my hint", true, isWriteable); } public Object getValue() { return myValue; } public void setValue(Object value) throws IllegalArgumentException, IllegalAccessException { if ("illegal".equals(value)) { IllegalArgumentException iae = new IllegalArgumentException(); TopManager.getDefault().getErrorManager(). annotate(iae, ErrorManager.ERROR, null, "invalid property value", null, null); throw iae; } System.out.println("SetValue called with value == " + value); Object oldVal = myValue; myValue = (String)value; firePropertyChange(getName(), oldVal, myValue); } } public static void main(String args[]) { TopManager.getDefault().getNodeOperation().explore(new InPlaceTestNode()); } }