问题
I have create new TopComonent for a client and then added new icon click action to the main toolbar and in view folder from main menu drop down list. But my problem is that what every position I set the action to it always puts it at start of toolbar but I need it at the end.
@ActionID(
category = "Build",
id = "some.action")
@ActionRegistration(
iconBase = "path.to.icom.image",
displayName = "someName")
@ActionReferences({
@ActionReference(path = "Menu/View", position = 400),
@ActionReference(path = "Toolbars/Refresh", position = 700)
})
@Messages("CTL_SomeAction=Refresh")
So can I edit the main layer.xml in netBeans??
回答1:
What you would need to do is to create an xml file (eg. layer.xml) in your module. Then you would copy and paste what you need from the generated-layer.xml file that can be found in under the file tab in the left window according to the following path: [Your Module Name]/build/classes/META-INF/generated-layer.xml. Generally according to your problem now, you might need the following info for your layer.xml file (if you give it that name):
<?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="Toolbars">
<folder name="Refresh">
<attr intvalue="1000" name="position"/>
</folder>
</folder>
</filesystem>
After doing this then validate your layer.xml file by right-clicking it and selecting "Validate XML" option. After doing this, then in the projects view, go to "important files" and open the Module Manifest file. At the end of the file add the following:
OpenIDE-Module-Layer: org/yourorg/modulename/layer.xml
After saving the manifest file and running your module, it should be ok.
来源:https://stackoverflow.com/questions/15831496/netbeans-7-3-customise-edit-toolbar-positions