This is about a Netbeans 7.1 platform app. Following this tutorial I added the following to the code of my NodetreeTopComponent, in order to change the context-menu:
@Override
public Action[] getActions() {
return new Action[] {new MyAction()};
}
private static class MyAction extends AbstractAction {
public MyAction () {
putValue (NAME, "New Whatever");
}
@Override
public void actionPerformed(ActionEvent e) {
NewWhateverTopComponent nk = new NewWhateverTopComponent();
nk.setVisible(true);
}
}
Unfortunately, this does exactly nothing. Right-clicking any node in my tree i still get just the default Menu (Copy, Properties). What have i overseen?
Thank you for any suggestions.
You need to override the
getActions()method of your Node not yourTopComponent. In the tutorial that you linked to refer to the section titled Actions and Nodes. Step one states:I believe this is where you’ve gone askew.