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 DataObjects 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"/>

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.

Source: NetBeans FAQ

Parent Category: Other API Tips