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:

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:

How to do this? The Outline component, which provides the table above, inherits from org.netbeans.swing.etable.ETable, which inherits from JTable. So, there's nothing new here:KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);outlineView1.getOutline().getInputMap(JCompo nent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(enter Key, "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 been discussed before, 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.


Read More about [Integrating an OutlineView with the Save Action...