NetBeans Platform specific Code Templates

In my last blog posts I’ve shown you some Code Templates you can use in order to speed up your Java coding. There are also some templates for NetBeans Platform APIs. Here’s an example:

Typing “2fo” converts a java.util.File to a NetBeans FileObject. When pressing the <tab> key, the Code  expands to:

FileObject fileObject = FileUtil.toFileObject(FileUtil.normalizeFile(file));

Typing “2do” converts the FileObject to a DataObject:

try {
 DataObject dataObject = DataObject.find(fileObject);

 } catch (DataObjectNotFoundException dataObjectNotFoundException) {

…and finally “2no” retrieves the corresponding Node.

Node node = dataObject.getNodeDelegate();

The last one is a template I created myself. More about this in another blog entry. And here’s a video how you can use these templates together to display a folder of your file system in the UI:

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>