01: /**
02: * Created on Dec 2, 2004
03: *
04: * @author karthikeyanr
05: *
06: */package wizard.ui;
07:
08: import java.awt.*;
09:
10: import javax.swing.*;
11: import javax.swing.tree.TreeCellRenderer;
12:
13: public class NavigationRenderer extends JLabel implements
14: TreeCellRenderer {
15: final private Color SELECTION_COLOR = Color.BLUE;
16:
17: final private Color NORMAL_COLOR = Color.BLACK;
18:
19: public NavigationRenderer() {
20: setHorizontalAlignment(SwingConstants.LEADING);
21: setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
22: setEnabled(true);
23: }
24:
25: public Component getTreeCellRendererComponent(JTree tree,
26: Object value, boolean selected, boolean expanded,
27: boolean leaf, int row, boolean hasFocus) {
28: String stringValue = tree.convertValueToText(value, selected,
29: expanded, leaf, row, hasFocus);
30: setText(stringValue);
31:
32: if (selected)
33: setForeground(SELECTION_COLOR);
34: else
35: setForeground(NORMAL_COLOR);
36:
37: setComponentOrientation(tree.getComponentOrientation());
38: setOpaque(false);
39: return this;
40: }
41: }
|