01: package vicazh.hyperpool;
02:
03: import javax.swing.*;
04: import javax.swing.tree.*;
05:
06: /**
07: * The general tree
08: *
09: * @author Victor Zhigunov
10: * @version 0.4.0
11: */
12: public class ITree extends JTree {
13: public ITree(TreeModel model) {
14: super (model);
15: }
16:
17: public void updateUI() {
18: super .updateUI();
19: setBackground(UIManager.getColor("Tree.selectionBackground"));
20: setCellRenderer(new ITreeRenderer());
21: setCellEditor(new ITreeEditor(
22: ((DefaultTreeCellRenderer) cellRenderer)
23: .getIconTextGap()));
24: TreeModel model = getModel();
25: if (model == null)
26: return;
27: DefaultMutableTreeNode root = (DefaultMutableTreeNode) model
28: .getRoot();
29: if (root != null)
30: updateUI(root);
31: }
32:
33: private void updateUI(DefaultMutableTreeNode node) {
34: for (int i = 0; i < node.getChildCount(); i++)
35: updateUI((DefaultMutableTreeNode) node.getChildAt(i));
36: Object o = node.getUserObject();
37: if (o instanceof IElement)
38: ((IElement) o).updateUI();
39: }
40: }
|