Geertjan's Blog

  • March 16, 2013

Extending the NetBeans Favorites Window

Geertjan Wielenga
Product Manager

URLs registered in the Favorites folder are rendered in the Favorites window. Rendering is done by the FavoritesNode, which is an internal class in the Favorites module, for each URL registered in the Favorites folder.

For example, here I've created a URL:

package org.my.fav;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openide.filesystems.FileUtil;
import org.openide.util.Utilities;
public class ConfigRootNode {
public static URL getNetBeansUser() throws MalformedURLException {
String s = System.getProperty("netbeans.user"); // NOI18N
File userDir = new File(s);
userDir = FileUtil.normalizeFile(userDir);
return Utilities.toURI(userDir).toURL();

And here the URL above is registered:

<folder name="Favorites">
<file name="UserDir.shadow">
<attr name="originalFile"
<attr name="position" intvalue="200"/>

Therefore, note that the only thing you can pass into the Favorites folder is a URL, nothing else, i.e., you have no control over the rendered Node, e.g., over its children. If that's what you want, either create a Node and register it in the Services window as shown here (assuming you're extending NetBeans IDE, since that's where that window comes from, not the NetBeans Platform) or simply create your own TopComponent and render your Nodes there.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.