If you are using module development support in 5.0 or later, you will manage the order of menu/toolbar/* items by the help of special node XML Layer which can be found in the Projects view (Ctrl-1) --> your module --> Important Files --> XML Layer --> <this layer in context>. Just find your menu/toolbar item and drag and drop it wherever you need. Appropriate content in the project metadata (layer file) will be generated for you. If you are curious about what it does in tha background or if you are using NetBeans 4.1 or earlier read further.
FileObjects have no partiticular order - the order in which the children of a folder are determined is undefined.
However, DataObjects can have a defined order. The way this works is, you use file attributes to specify what files should be before and after your file. Filesystem folders won't care about this information, but the DataObject s for folders do (call DataFolder.find (FileObject) to get one). It works like this:
<folder name="SomeFolder"/> <attr name="fileBefore/someFile" boolvalue="true"/> <file name="someFile"/> <attr name="someFile/fileAfter" boolvalue="true"/> <folder/>
Notice where the attributes are specified: on the folder, not the file! The order of the attributes in the XML file is not important - they can be anywhere - but it is a NetBeans coding convention to specify them as shown above - before attr, file, after attr - so that someone who wants to read/debug XML layers can remain at least reasonably sane.
If you are really interested in the nitty gritty of how and why this works, see the javadoc on topological sort.
You may be wondering why is there a value of "true" for each attribute.
Bear in mind that using an ordering attribute a/b only ensures that a comes somewhere before b=. It does not guarantee that =b will immediately follow a=. But if you know that =a is normally followed immediately by c=, then using both the attributes =a/b and b/c will put b between them.
NetBeans 6.x uses a different system based on numeric position attributes. For all details, see: FolderOrdering103187