View Javadoc

1   /**
2    * 
3    */
4   package sk.stuba.fiit.foo07.genex.gui;
5   
6   import java.awt.Component;
7   
8   import javax.swing.JTree;
9   import javax.swing.tree.DefaultMutableTreeNode;
10  import javax.swing.tree.DefaultTreeCellRenderer;
11  
12  import sk.stuba.fiit.foo07.genex.beans.Test;
13  
14  /**
15   * @author _mizu_
16   * 
17   */
18  public class TreeIconRenderer extends DefaultTreeCellRenderer {
19  
20      /**
21       * 
22       */
23      private static final long serialVersionUID = 1936460107108983495L;
24  
25      @Override
26      public Component getTreeCellRendererComponent(JTree tree, Object value,
27              boolean sel, boolean expanded, boolean leaf, int row,
28              boolean hasFocus) {
29  
30          Object obj = ((DefaultMutableTreeNode) value).getUserObject();
31          leaf = obj instanceof Test ? true : false;
32  
33          return super.getTreeCellRendererComponent(tree, value, sel, expanded,
34                  leaf, row, hasFocus);
35      }
36  
37  }