问题
I am having a hard time customizing my menus in the NetBeans Platform. The examples I've seen require you to have a Layer file which I don't believe I have in my NetBeans Platform Project.
To hide a menu via layers you are supposed to do this:
<folder name="Menu">
<folder name="View_hidden"/>
<folder name="Edit">
<file name="org-openide-actions-FindAction.shadow_hidden"/>
</folder>
</folder>
I would like to know the annotation way of hiding menus. However, if this is the only way to do it, where would I put the layer file and what would i name it?
回答1:
The only way to hide menu items is to add the entries to your layer file. To add a layer file to your module you'll need to
- Create a new xml file called
layer.xml
in any package in your module - Register the new layer file in your Module Manifest file (under the Important Files node) using the following pattern
OpenIDE-Module-Layer: com/example/layer.xml
wherecom/example
is the package that you created the layer file in
In the layer.xml file you'll need to start with the following structure:
<?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>
</filesystem>
Shortcut for adding the _hidden nodes
Once you've added a layer file to your module you can get NetBeans to add the necessary _hidden
nodes by:
- Expand the Important Files node in your module (any module will do but if/when this module is uninstalled then the layer file is also uninstalled)
- Expand the XML Layer node (this is added once you've manually added the layer.xml file as above)
- Expand the this layer in context node
- Expand the Menu Bar node
- Right click the menu item you want to hide and select Delete
来源:https://stackoverflow.com/questions/10282081/how-do-i-hide-menus-without-a-layer-file-in-netbeans-platform