01: /* (swing1.1) */
02:
03: package jp.gr.java_conf.tame.swing.tree;
04:
05: import java.util.Enumeration;
06: import javax.swing.tree.DefaultMutableTreeNode;
07:
08: /**
09: * @version 1.0 01/11/99
10: */
11: public class CheckNode extends DefaultMutableTreeNode {
12:
13: public final static int SINGLE_SELECTION = 0;
14: public final static int DIG_IN_SELECTION = 4;
15: protected int selectionMode;
16: protected boolean isSelected;
17:
18: public CheckNode() {
19: this (null);
20: }
21:
22: public CheckNode(Object userObject) {
23: this (userObject, true, false);
24: }
25:
26: public CheckNode(Object userObject, boolean allowsChildren,
27: boolean isSelected) {
28: super (userObject, allowsChildren);
29: this .isSelected = isSelected;
30: setSelectionMode(DIG_IN_SELECTION);
31: }
32:
33: public void setSelectionMode(int mode) {
34: selectionMode = mode;
35: }
36:
37: public int getSelectionMode() {
38: return selectionMode;
39: }
40:
41: public void setSelected(boolean isSelected) {
42: this .isSelected = isSelected;
43:
44: if ((selectionMode == DIG_IN_SELECTION) && (children != null)) {
45: Enumeration enumeration = children.elements();
46: while (enumeration.hasMoreElements()) {
47: CheckNode node = (CheckNode) enumeration.nextElement();
48: node.setSelected(isSelected);
49: }
50: }
51: }
52:
53: public boolean isSelected() {
54: return isSelected;
55: }
56:
57: // If you want to change "isSelected" by CellEditor,
58: /*
59: public void setUserObject(Object obj) {
60: if (obj instanceof Boolean) {
61: setSelected(((Boolean)obj).booleanValue());
62: } else {
63: super.setUserObject(obj);
64: }
65: }
66: */
67:
68: }
|