When the user clicks the Enter key in your OutlineView, you'd like the Save Action to become enabled, so that the Save button (and Save menu item) can be clicked. For example, while the user is changing something, as shown below, the Save button should not be enabled:
[IMG]http://blogs.sun.com/geertjan/resource/outlineview-save-1.png[/IMG]
However, once the user is happy with the change and confirms it by pressing the Enter key, the Save button should be enabled, as shown below:
[IMG]http://blogs.sun.com/geertjan/resource/outlineview-save-2.png[/IMG]
How to do this? The Outline component, which provides the table above, inherits from [URL="http://bits.netbeans.org/dev/javadoc/org-netbeans-swing-outline/org/netbeans/swing/etable/ETable.html"]org.netbeans.swing.etable.ETable[/URL], which inherits from JTable. So, there's nothing new here:KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);outlineView1.getOutline().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(enterKey, "enter");outlineView1.getOutline().getActionMap().put("enter", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { fire(true); }});
When Enter is pressed, "true" is passed to "fire". And that's [URL="http://blogs.sun.com/geertjan/entry/the_divorce_of_savecookies_from"]been discussed before[/URL], i.e., this is where you add the SaveCookie to the InstanceContent:public void fire(boolean modified) { if (modified) { //If the text is modified, //we add SaveCookie impl to Lookup: ic.add(impl); } else { //Otherwise, we remove the SaveCookie impl from the lookup: ic.remove(impl); }}
That's all. Now you've integrated your OutlineView with the NetBeans Platform's save functionality.

[url=http://blogs.sun.com/geertjan/entry/integrating_an_outlineview_with_the]Read More about [Integrating an OutlineView with the Save Action...[/url]