-
Notifications
You must be signed in to change notification settings - Fork 1
DevFaqChangeNodeAppearance
It’s pretty simple to change the font color, style or weight for your node’s label. Simply override getHtmlDisplayName
and provide some HTML in your return value. (An example can be found in this tutorial.) Here is another example:
public class MovieNode extends AbstractNode {
private Movie movie;
public MovieNode(Movie key) {
super(Children.LEAF, Lookups.fixed(new Object[]{key}));
this.movie = key;
setName(key.getTitle());
setDisplayName(key.getTitle());
getHandle();
setIconBaseWithExtension("org/nb/marilyn/pics/marilyn.gif");
}
@Override
public String getHtmlDisplayName() {
return "*" + this.getDisplayName() + "*";
}
}
The javadoc for the HtmlRenderer class explains what subset of HTML is supported. You can also change the icon’s node by overriding various methods such as getIcon(int type)
or {getOpenedIcon()
}.
It’s also possible, but far more difficult, to control other aspects of the node’s appearance; for example, drawing a box around the node or changing its background color. To do this you must create or modify the explorer view in which the node is rendered. Fabrizio Giudici posted code that illustrates this on the dev@openide
list.
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqChangeNodeAppearance , that was last modified by NetBeans user Jtulach on 2010-07-24T19:19:45Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.
Apache NetBeans is an effort undergoing incubation at The Apache Software Foundation (ASF).
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
This wiki is an experiment pending Apache NetBeans Community approval.