/**
 * Implement the TreeCellRender,to change the display style.
 *
 * You can add the icon if you need.
 */
class CellRender extends JLabel
    implements TreeCellRenderer {
  protected Color selectedBackground;
  protected Color selectedForeground;
  protected Color noselectedBackground;
  protected Color noselectedForeground;
  protected Color overflowBackground = Color.yellow;
  protected Color overflowForeground = Color.red;
  protected Color overflowSelectedBG = Color.green;
  protected Color overflowSelectedFG = Color.black;
  public CellRender()
  {
    super();
  }
  /**
   * Sets the value of the current tree cell to <code>value</code>.
   *
   * @return the <code>Component</code> that the renderer uses to draw
the value
   * @param tree JTree
   * @param value Object
   * @param selected boolean
   * @param expanded boolean
   * @param leaf boolean
   * @param row int
   * @param hasFocus boolean
   * @todo Implement this javax.swing.tree.TreeCellRenderer method
   */
  public Component getTreeCellRendererComponent(JTree tree, Object
value,
                                                boolean selected,
                                                boolean expanded,
boolean leaf,
                                                int row, boolean
hasFocus) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    NodeData nd ;//NodeData 是你自定义的包含“标记”属性的类
    nd = (NodeData) node.getUserObject();
      if (nd.标记.equals("yes")) {
          if (selected)
          {
            //this.setForeground(Color.green);//你可以自己定义颜色,是定义鼠标点击之后的颜色
          }
          else
          {
            this.setForeground(Color.red);
          }
        }
        else {
          if(selected)
          {
            this.setForeground(Color.///);
          }
          else
      {
            this.setForeground(Color.green);
          }
        }      this.setText(value.toString());
    return this;
  }}