[英]Adding a Menu Item to Netbeans platform Menu Bar
I'm trying to create a mock menu for a module of my netbeans platform project (which I'm starting). 我正在尝试为我的netbeans平台项目的模块(我正在开始)创建一个模拟菜单。
I want to create a new entry "New" in "File" that would have "New Project" and "New Module". 我想在“文件”中创建一个具有“新项目”和“新模块”的新条目“新”。
In Important Files -> Xml Layer -> this layer in context -> Menu Bar -> File I've created a new folder "New", and it displays as it should. 在“重要文件”->“ Xml层”->“上下文”->“菜单栏”->“文件”中,我创建了一个新文件夹“ New”,它按原样显示。
Then I've added two empty files, "New Project" and "New Module", but they don't show. 然后,我添加了两个空文件“ New Project”和“ New Module”,但它们没有显示。
Here's layer.xml: 这是layer.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Actions">
<folder name="File"/>
</folder>
<folder name="Menu">
<folder name="File">
<folder name="New">
<file name="New Module" url="New Module_2">
<attr name="requireProject" boolvalue="false"/>
<attr name="position" intvalue="800"/>
</file>
<file name="New Project" url="New Project_3">
<attr name="requireProject" boolvalue="false"/>
<attr name="position" intvalue="600"/>
</file>
</folder>
</folder>
</folder>
</filesystem>
I've deleted and created these files several times, hence the suffixes. 我已经多次删除并创建了这些文件,因此有了后缀。 The only thing I've added is positions.
我唯一添加的是职位。
I guess I'm either missing something or I misinterpreted something. 我想我要么丢失了一些东西,要么我误解了一些东西。 I've read the documentation, but cannot find the answer.
我已经阅读了文档,但是找不到答案。
So, how do I add and display a Menu Item? 那么,如何添加和显示菜单项?
I think that your <file name
should point to instances of Action. 我认为您的
<file name
应指向Action实例。 For example: 例如:
<file name="org-netbeans-core-actions-SystemExit.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-netbeans-core-actions-SystemExit.instance"/>
<attr name="position" intvalue="2600"/>
</file>
From NetBeans documentation: 从NetBeans文档中:
The main menu of the application is composed by reading Menu/ folder in the layer.
该应用程序的主菜单是通过阅读该层中的Menu /文件夹组成的。 A sub folder is treated as a sub menu.
子文件夹被视为子菜单。 Instances of individual files (usually .instance or .shadow) may then represent Action or JMenuItem or JSeparator.
单个文件的实例(通常是.instance或.shadow)然后可以表示Action或JMenuItem或JSeparator。
source: http://bits.netbeans.org/dev/javadoc/layers.html 来源: http : //bits.netbeans.org/dev/javadoc/layers.html
Also here: http://wiki.netbeans.org/DevFaqSystemFilesystem 同样在这里: http : //wiki.netbeans.org/DevFaqSystemFilesystem
You can easily create actions with the wizard. 您可以使用向导轻松创建操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.