gpt4 book ai didi

java - 更改 NodeTree 的弹出菜单

转载 作者:行者123 更新时间:2023-12-01 15:34:03 24 4
gpt4 key购买 nike

这是关于 Netbeans 7.1 平台应用程序。正在关注this tutorial我将以下内容添加到 NodetreeTopComponent 的代码中,以更改上下文菜单:

 @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);
}

}

不幸的是,这根本没有任何作用。右键单击树中的任何节点,我仍然只能得到默认菜单(复制、属性)。我监督了什么?

感谢您的任何建议。

最佳答案

...I added the following to the code of my NodetreeTopComponent...

您需要重写 NodegetActions() 方法,而不是 TopComponent。在您链接到的教程中,请参阅标题为 Actions and Nodes 的部分。 。第一步说明:

Override the getActions() method of EventNode as follows

我相信这就是你歪曲的地方。

关于java - 更改 NodeTree 的弹出菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9192923/

24 4 0