1 21 22 package swingwtx.swing.tree; 23 24 import swingwtx.swing.*; 25 import swingwt.awt.*; 26 27 public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer { 28 29 protected boolean hasFocus; 30 protected boolean selected; 31 32 public Component getTreeCellRendererComponent(swingwtx.swing.JTree tree, 33 Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { 34 35 this.hasFocus = hasFocus; 36 this.selected = selected; 37 38 if (leaf) 40 if (expanded) 41 setIcon(openIcon); 42 else 43 setIcon(closedIcon); 44 else 45 setIcon(leafIcon); 46 47 setText(value.toString()); 48 return this; 49 } 50 51 public Color getTextSelectionColor() { return SystemColor.controlHighlight; } 52 public Color getTextNonSelectionColor() { return SystemColor.controlText; } 53 54 ImageIcon leafIcon = new ImageIcon(getClass().getResource("/swingwtx/swing/tree/doc.gif")); 55 ImageIcon openIcon = new ImageIcon(getClass().getResource("/swingwtx/swing/tree/folderopen.gif")); 56 ImageIcon closedIcon = new ImageIcon(getClass().getResource("/swingwtx/swing/tree/folder.gif")); 57 58 public Icon getLeafIcon() { return leafIcon; } 59 public Icon getOpenIcon() { return openIcon; } 60 public Icon getClosedIcon() { return closedIcon; } 61 62 } 63 | Popular Tags |