Java Code Examples for javax.swing.tree.DefaultTreeCellRenderer#setIcon()

The following examples show how to use javax.swing.tree.DefaultTreeCellRenderer#setIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreePanel.java    From chipster with MIT License 6 votes vote down vote up
public Component getTreeCellRendererComponent(JTree tree,
        Object value, boolean selected, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {
    
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    DataItem element = (DataItem) node.getUserObject();

    DefaultTreeCellRenderer renderer = 
    	(DefaultTreeCellRenderer)super.getTreeCellRendererComponent(tree, value, selected, 
    			expanded,leaf, row, hasFocus);
    
    renderer.setIcon(application.getIconFor(element));
    renderer.setText(element.toString() + " ");
   
  return this;
}
 
Example 2
Source File: MindMapTreeCellRenderer.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public Component getTreeCellRendererComponent(@Nonnull final JTree tree, @Nonnull final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
  final DefaultTreeCellRenderer result = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
  if (value instanceof Topic) {
    result.setIcon(getIconForTopic((Topic) value));
    result.setText(extractTextFromTopic((Topic) value));
  }
  return result;
}
 
Example 3
Source File: MindMapTreeCellRenderer.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
  final DefaultTreeCellRenderer result = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
  if (value instanceof Topic) {
    result.setIcon(getIconForTopic((Topic) value));
    result.setText(extractTextFromTopic((Topic) value));
  }
  return result;
}
 
Example 4
Source File: MindMapTreeCellRenderer.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
  final DefaultTreeCellRenderer result = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
  if (value instanceof Topic) {
    result.setIcon(getIconForTopic((Topic) value));
    result.setText(extractTextFromTopic((Topic) value));
  }
  return result;
}