01: /*
02: * @(#)FileTreeCellRenderer.java 9/12/2005
03: *
04: * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
05: */
06: package com.jidesoft.plaf.basic;
07:
08: import javax.swing.*;
09: import javax.swing.tree.DefaultTreeCellRenderer;
10: import java.awt.*;
11:
12: class BasicFileSystemTreeCellRenderer extends DefaultTreeCellRenderer {
13: @Override
14: public Component getTreeCellRendererComponent(JTree tree,
15: Object value, boolean sel, boolean expanded, boolean leaf,
16: int row, boolean hasFocus) {
17: if (value instanceof BasicFileSystemTreeNode) {
18: BasicFileSystemTreeNode fileTreeNode = (BasicFileSystemTreeNode) value;
19: JLabel label = (JLabel) super .getTreeCellRendererComponent(
20: tree, fileTreeNode.getName(), sel, expanded, leaf,
21: row, hasFocus);
22: try {
23: label.setIcon(fileTreeNode.getIcon());
24: } catch (Exception e) {
25: System.out.println(fileTreeNode.getFile()
26: .getAbsolutePath());
27: }
28: return label;
29: }
30: return super.getTreeCellRendererComponent(tree, value, sel,
31: expanded, leaf, row, hasFocus);
32: }
33: }
|