|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.swing.visuals.CheckBoxTree
public class CheckBoxTree
The CheckBoxTree is a subclass of JTree that adds the capability of having checkboxes for each
node in the tree. The checked state of each node is stored in a TreeSelectionModel
.
The CheckBoxTree gives the user the option of having checkboxes on the leaf nodes and/or the parent nodes
in the tree.
Field Summary | |
---|---|
static int |
ALL_CHILDREN_SELECTED
|
protected javax.swing.JCheckBox |
checkBox
|
protected boolean |
checkBoxOnLeafNodes
|
protected boolean |
checkBoxOnParentNodes
|
protected boolean |
checkBoxOnRootNode
|
protected boolean |
checkBoxShouldCheckChildren
|
protected boolean |
checkBoxShouldCheckParents
|
protected javax.swing.tree.TreeSelectionModel |
checkedTreeModel
|
protected CheckBoxTreeCellRendererWrapper |
checkRenderer
|
static int |
NO_CHECKBOX
|
static int |
NODE_ALL_CHILDREN_SELECTED
|
static int |
NODE_NO_CHILDREN_SELECTED
|
static int |
NODE_SELECTED
|
static int |
NODE_SOME_CHILDREN_SELECTED
|
static int |
NOTHING_SELECTED
|
static int |
POSTORDER
|
static int |
PREORDER
|
protected boolean |
showSelectionIcon
|
static int |
SOME_CHILDREN_SELECTED
|
Fields inherited from interface com.sas.swing.visuals.util.LayoutConstants |
---|
DOTS_BUTTON_INSETS, EMPTY_INSETS, HGAP, HMARGIN, INDENTED_BORDER, TAB_BORDER, TEXTFIELD_INSETS, VGAP, VMARGIN |
Constructor Summary | |
---|---|
CheckBoxTree()
Default constructor, trre model will be the default tree model and both parent and leaf nodes will have checkboxes. |
|
CheckBoxTree(javax.swing.tree.TreeModel model)
Creates a CheckBoxTree and will use the given tree model as the model. |
Method Summary | |||
---|---|---|---|
void |
checkChildren(javax.swing.tree.TreePath path,
boolean setChecked,
boolean recursive)
This method is used to check or uncheck the children nodes for the given node. |
||
void |
checkParents(javax.swing.tree.TreePath path,
boolean setChecked,
boolean recursive)
This method is used to check or uncheck the children nodes for the given node. |
||
void |
checkPath(javax.swing.tree.TreePath path,
boolean setChecked,
boolean makeVisible)
This method is used to checks or uncheck the node represented by the given path. |
||
javax.swing.tree.TreeSelectionModel |
createDefaultCheckedModel()
Creates the default TreeSelectionModel which stores the check state of each node in the tree. |
||
void |
createDefaultIcons()
Creates the defaults icons to use for the various check states |
||
javax.swing.Icon |
getAllChildrenSelectedIcon()
Returns the icon that gets used for the ALL_CHILDREN_SELECTED checked state. |
||
java.util.List |
getCheckedChildrenPaths(javax.swing.tree.TreePath path)
Returns a |
javax.swing.tree.TreeSelectionModel |
getCheckedModel()
Returns the model that is used for storing the checked state of each node in the tree. |
java.lang.Object[] |
getCheckedObjects()
Returns all the objects which are checked in the tree. |
||
java.lang.Object[] |
getCheckedObjects(int order)
Returns all the objects which are checked in the tree using the given order. |
||
int |
getCheckedState(javax.swing.tree.TreePath path)
Returns the state of the checkbox and its icon for the given TreePath. |
||
int |
getDelayForCursorChange()
Returns the delay in milliseconds for the cursor change to take. |
||
javax.swing.Icon |
getIconForCheckedState(int state)
Return the icon the gets used for the given state. |
||
javax.swing.Icon |
getNodeAndAllChildrenSelectedIcon()
Returns the icon that gets used for the NODE_ALL_CHILDREN_SELECTED checked state. |
||
javax.swing.Icon |
getNodeAndSomeChildrenSelectedIcon()
Returns the icon that gets used for the NODE_SOME_CHILDREN_SELECTED checked state. |
||
javax.swing.Icon |
getNodeSelectedIcon()
Returns the icon that gets used for the NODE_SELECTED and
NODE_NO_CHILDREN_SELECTED checked state. |
||
javax.swing.Icon |
getNoneSelectedIcon()
Returns the icon that gets used for the NOTHING_SELECTED checked state. |
||
javax.swing.Icon |
getSomeChildrenSelectedIcon()
Returns the icon that gets used for the SOME_CHILDREN_SELECTED checked state. |
||
boolean |
isChangeCursorWhenBusy()
Returns true if the busy cursor will show when the tree is taking more then the set delay for a cursor change. |
||
boolean |
isCheckBoxOnLeafNodes()
Returns true if checkboxes are to be shown on leaf nodes or not. |
||
boolean |
isCheckBoxOnParentNodes()
Returns true if checkboxes are to be shown on parent nodes or not. |
||
boolean |
isCheckBoxOnRootNode()
|
||
boolean |
isCheckBoxShouldCheckChildren()
|
||
boolean |
isCheckBoxShouldCheckParents()
|
||
boolean |
isCheckBoxVisibleForPath(javax.swing.tree.TreePath path)
Returns true if the given path has a checkbox, false otherwise. |
||
boolean |
isCheckBoxVisibleForRow(int row)
Returns true if the given row has a checkbox, false otherwise. |
||
boolean |
isIconVisibleForPath(javax.swing.tree.TreePath path)
Returns true if the selection icon is visible for the given path, the icon can be used to select or deselect all the children checkboxes for the given row. |
||
boolean |
isIconVisibleForRow(int row)
Returns true if the selection icon is visible for the given row, the icon can be used to select or deselect all the children checkboxes for the given row. |
||
boolean |
isShowSelectionIcon()
|
||
void |
propertyChange(java.beans.PropertyChangeEvent e)
|
||
void |
setAllChildrenSelectedIcon(javax.swing.Icon newIcon)
Sets the icon that gets used with the ALL_CHILDREN_SELECTED checked state. |
||
void |
setChangeCursorWhenBusy(boolean shouldChangeCursor)
Sets whether the busy cursor will show when the tree is taking more then the set delay for a cursor change. |
||
void |
setCheckBoxOnLeafNodes(boolean checksOnLeaves)
Sets whether the leaf nodes should contain checkboxes or not, default is true. |
||
void |
setCheckBoxOnParentNodes(boolean checksOnParents)
Sets whether the parent nodes should contain checkboxes or not, default is true. |
||
void |
setCheckBoxOnRootNode(boolean checkBoxOnRootNode)
|
||
void |
setCheckBoxShouldCheckChildren(boolean checkBoxShouldCheckChildren)
|
||
void |
setCheckBoxShouldCheckParents(boolean checkBoxShouldCheckParents)
|
||
void |
setCheckedModel(javax.swing.tree.TreeSelectionModel newModel)
Sets the new model that is used for storing the checked state of each node. |
||
void |
setDelayForCursorChange(int delayToChangeCursor)
Sets the time in milliseconds for a cursor change to take place. |
||
void |
setModel(javax.swing.tree.TreeModel newModel)
Sets the TreeModel that will provide the data. |
||
void |
setNodeAndAllChildrenSelectedIcon(javax.swing.Icon newIcon)
Sets the icon that gets used with the NODE_ALL_CHILDREN_SELECTED checked state. |
||
void |
setNodeAndSomeChildrenSelectedIcon(javax.swing.Icon newIcon)
Sets the icon that gets used with the NODE_SOME_CHILDREN_SELECTED checked state. |
||
void |
setNodeSelectedIcon(javax.swing.Icon newIcon)
Sets the icon that gets used with the NODE_SELECTED and
NODE_NO_CHILDREN_SELECTED checked state. |
||
void |
setNoneSelectedIcon(javax.swing.Icon newIcon)
Sets the icon that gets used with the NOTHING_SELECTED checked state. |
||
void |
setRootVisible(boolean visible)
Determines whether or not the root node from the TreeModel is visible. |
||
void |
setShowSelectionIcon(boolean showSelectionIcon)
|
||
void |
setSomeChildrenSelectedIcon(javax.swing.Icon newIcon)
Sets the icon that gets used with the SOME_CHILDREN_SELECTED checked state. |
||
void |
setWrapperCellRenderer(javax.swing.tree.TreeCellRenderer newRenderer)
Method setWrapperCellRenderer. |
||
void |
treeCollapsed(javax.swing.event.TreeExpansionEvent event)
Invoked when the tree fires a TreeExpansionEvent to the treeCollapsed method. |
||
void |
treeExpanded(javax.swing.event.TreeExpansionEvent event)
Invoked when the tree fires a TreeExpansionEvent to the treeExpanded method. |
||
void |
treeNodesChanged(javax.swing.event.TreeModelEvent e)
Invoked when this tree's TreeModel fires a TreeModelEvent to the treeNodesChanged method. |
||
void |
treeNodesInserted(javax.swing.event.TreeModelEvent e)
Invoked when this tree's TreeModel fires a TreeModelEvent to the treeNodesInserted method. |
||
void |
treeNodesRemoved(javax.swing.event.TreeModelEvent e)
Invoked when this tree's TreeModel fires a TreeModelEvent to the treeNodesRemoved method. |
||
void |
treeStructureChanged(javax.swing.event.TreeModelEvent e)
Invoked when this tree's TreeModel fires a TreeModelEvent to the treeStructureChanged method. |
||
void |
treeWillCollapse(javax.swing.event.TreeExpansionEvent event)
Invoked when the tree fires a TreeExpansionEvent to the treeWillCollapse method. |
||
void |
treeWillExpand(javax.swing.event.TreeExpansionEvent event)
Invoked when the tree fires a TreeExpansionEventt to the treeWillExpand method. |
||
void |
updateUI()
Notification from the UIManager that the L&F has changed. |
||
void |
valueChanged(javax.swing.event.TreeSelectionEvent event)
Messaged when the selection changes in the tree we're displaying for. |
Field Detail |
---|
protected javax.swing.JCheckBox checkBox
protected CheckBoxTreeCellRendererWrapper checkRenderer
protected javax.swing.tree.TreeSelectionModel checkedTreeModel
protected boolean checkBoxOnLeafNodes
protected boolean checkBoxOnParentNodes
protected boolean checkBoxOnRootNode
protected boolean showSelectionIcon
protected boolean checkBoxShouldCheckChildren
protected boolean checkBoxShouldCheckParents
public static final int NOTHING_SELECTED
public static final int NODE_SELECTED
public static final int NODE_SOME_CHILDREN_SELECTED
public static final int NODE_ALL_CHILDREN_SELECTED
public static final int NODE_NO_CHILDREN_SELECTED
public static final int SOME_CHILDREN_SELECTED
public static final int ALL_CHILDREN_SELECTED
public static final int NO_CHECKBOX
public static final int PREORDER
public static final int POSTORDER
Constructor Detail |
---|
public CheckBoxTree()
public CheckBoxTree(javax.swing.tree.TreeModel model)
model
- the TreeModel to use as the data modelMethod Detail |
---|
public boolean isChangeCursorWhenBusy()
setChangeCursorWhenBusy(boolean)
public void setChangeCursorWhenBusy(boolean shouldChangeCursor)
shouldChangeCursor
- true if a busy cursor is to be used, false otherwiseisChangeCursorWhenBusy()
public int getDelayForCursorChange()
setDelayForCursorChange(int)
public void setDelayForCursorChange(int delayToChangeCursor)
delayToChangeCursor
- the new time in milliseconds for a cursor change to take placegetDelayForCursorChange()
public boolean isCheckBoxOnLeafNodes()
setCheckBoxOnLeafNodes(boolean)
public void setCheckBoxOnLeafNodes(boolean checksOnLeaves)
checksOnLeaves
- true to have checkboxes on leaf nodes, false otherwiseisCheckBoxOnLeafNodes()
public boolean isCheckBoxOnParentNodes()
setCheckBoxOnParentNodes(boolean)
public void setCheckBoxOnParentNodes(boolean checksOnParents)
checksOnParents
- true to have checkboxes on parent nodes, false otherwiseisCheckBoxOnParentNodes()
public void createDefaultIcons()
setNoneSelectedIcon(Icon)
,
setAllChildrenSelectedIcon(Icon)
,
setNodeSelectedIcon(Icon)
,
setNodeAndAllChildrenSelectedIcon(Icon)
,
setNodeAndSomeChildrenSelectedIcon(Icon)
,
setSomeChildrenSelectedIcon(Icon)
public void setNoneSelectedIcon(javax.swing.Icon newIcon)
NOTHING_SELECTED
checked state.
newIcon
- the icon to set for the NOTHING_SELECTED
stategetNoneSelectedIcon()
public javax.swing.Icon getNoneSelectedIcon()
NOTHING_SELECTED
checked state.
setNoneSelectedIcon(Icon)
public void setAllChildrenSelectedIcon(javax.swing.Icon newIcon)
ALL_CHILDREN_SELECTED
checked state.
newIcon
- the icon to set for the ALL_CHILDREN_SELECTED
stategetAllChildrenSelectedIcon()
public javax.swing.Icon getAllChildrenSelectedIcon()
ALL_CHILDREN_SELECTED
checked state.
setAllChildrenSelectedIcon(Icon)
public void setNodeSelectedIcon(javax.swing.Icon newIcon)
NODE_SELECTED
and
NODE_NO_CHILDREN_SELECTED
checked state.
newIcon
- the icon to set for the NODE_SELECTED
and
NODE_NO_CHILDREN_SELECTED
stategetNodeSelectedIcon()
public javax.swing.Icon getNodeSelectedIcon()
NODE_SELECTED
and
NODE_NO_CHILDREN_SELECTED
checked state.
setNodeSelectedIcon(Icon)
public void setNodeAndAllChildrenSelectedIcon(javax.swing.Icon newIcon)
NODE_ALL_CHILDREN_SELECTED
checked state.
newIcon
- the icon to set for the NODE_ALL_CHILDREN_SELECTED
stategetNodeAndAllChildrenSelectedIcon()
public javax.swing.Icon getNodeAndAllChildrenSelectedIcon()
NODE_ALL_CHILDREN_SELECTED
checked state.
setNodeAndAllChildrenSelectedIcon(Icon)
public void setNodeAndSomeChildrenSelectedIcon(javax.swing.Icon newIcon)
NODE_SOME_CHILDREN_SELECTED
checked state.
newIcon
- the icon to set for the NODE_SOME_CHILDREN_SELECTED
stategetNodeAndSomeChildrenSelectedIcon()
public javax.swing.Icon getNodeAndSomeChildrenSelectedIcon()
NODE_SOME_CHILDREN_SELECTED
checked state.
setNodeAndSomeChildrenSelectedIcon(Icon)
public void setSomeChildrenSelectedIcon(javax.swing.Icon newIcon)
SOME_CHILDREN_SELECTED
checked state.
newIcon
- the icon to set for the SOME_CHILDREN_SELECTED
stategetSomeChildrenSelectedIcon()
public javax.swing.Icon getSomeChildrenSelectedIcon()
SOME_CHILDREN_SELECTED
checked state.
setSomeChildrenSelectedIcon(Icon)
public boolean isCheckBoxVisibleForRow(int row)
row
- the row index in the tree
public boolean isCheckBoxVisibleForPath(javax.swing.tree.TreePath path)
path
- the path to the node that is in question of whther a checkbox is
present or not
public boolean isIconVisibleForRow(int row)
row
- the row index in question
public boolean isIconVisibleForPath(javax.swing.tree.TreePath path)
path
- the path to the node in question
public void updateUI()
updateUI
in class javax.swing.JTree
public void setModel(javax.swing.tree.TreeModel newModel)
setModel
in class javax.swing.JTree
newModel
- the TreeModel that is to provide the datapublic javax.swing.tree.TreeSelectionModel createDefaultCheckedModel()
public javax.swing.tree.TreeSelectionModel getCheckedModel()
setCheckedModel(TreeSelectionModel)
public void setCheckedModel(javax.swing.tree.TreeSelectionModel newModel)
newModel
- the new checked state modelgetCheckedModel()
public java.lang.Object[] getCheckedObjects()
public java.lang.Object[] getCheckedObjects(int order)
order
- needs to be either PREORDER or POSTORDER
public int getCheckedState(javax.swing.tree.TreePath path)
path
- the TreePath the node in question
public javax.swing.Icon getIconForCheckedState(int state)
state
- the state of the node
public void checkPath(javax.swing.tree.TreePath path, boolean setChecked, boolean makeVisible)
makeVisible
is set to true, the tree will expand to show the node and
will scroll to show it in its view.
path
- the path to the node to either check or unchecksetChecked
- true to check the checkbox for the node, false otherwisemakeVisible
- true to ensure that the node identified by path is currently viewable, false otherwisepublic void checkChildren(javax.swing.tree.TreePath path, boolean setChecked, boolean recursive)
recursive
is set to true, then the method will recurse through all nodes of the
path, otherwise it will just affect the immediate children of the path.
path
- the TreePath to the node whose children are affectedsetChecked
- true to check the children nodes, false otherwiserecursive
- true to recurse through all children of the path, false to only affect
the immediate children of the nodepublic void checkParents(javax.swing.tree.TreePath path, boolean setChecked, boolean recursive)
recursive
is set to true, then the method will recurse through all nodes of the
path, otherwise it will just affect the immediate children of the path.
path
- the TreePath to the node whose children are affectedsetChecked
- true to check the children nodes, false otherwiserecursive
- true to recurse through all children of the path, false to only affect
the immediate children of the nodepublic java.util.List getCheckedChildrenPaths(javax.swing.tree.TreePath path)
List
of all the TreePaths who have a selected checkbox
and are a child of the given TreePath.
path
- the path to the node whose child nodes are to be returned if they are checked
public void setRootVisible(boolean visible)
setRootVisible
in class javax.swing.JTree
visible
- true if the root node of the tree is to be displayed, false otherwisepublic void treeNodesChanged(javax.swing.event.TreeModelEvent e)
treeNodesChanged
in interface javax.swing.event.TreeModelListener
e
- the TreeModelEventTreeModelListener.treeNodesChanged(TreeModelEvent)
public void treeNodesInserted(javax.swing.event.TreeModelEvent e)
treeNodesInserted
in interface javax.swing.event.TreeModelListener
e
- the TreeModelEventTreeModelListener.treeNodesInserted(TreeModelEvent)
public void treeNodesRemoved(javax.swing.event.TreeModelEvent e)
treeNodesRemoved
in interface javax.swing.event.TreeModelListener
e
- the TreeModelEventTreeModelListener.treeNodesRemoved(TreeModelEvent)
public void treeStructureChanged(javax.swing.event.TreeModelEvent e)
treeStructureChanged
in interface javax.swing.event.TreeModelListener
e
- the TreeModelEventTreeModelListener.treeStructureChanged(TreeModelEvent)
public void treeCollapsed(javax.swing.event.TreeExpansionEvent event)
treeCollapsed
in interface javax.swing.event.TreeExpansionListener
event
- TreeExpansionEventTreeExpansionListener.treeCollapsed(TreeExpansionEvent)
public void treeExpanded(javax.swing.event.TreeExpansionEvent event)
treeExpanded
in interface javax.swing.event.TreeExpansionListener
event
- TreeExpansionEventTreeExpansionListener.treeExpanded(TreeExpansionEvent)
public void treeWillCollapse(javax.swing.event.TreeExpansionEvent event)
treeWillCollapse
in interface javax.swing.event.TreeWillExpandListener
event
- TreeExpansionEventTreeWillExpandListener.treeWillCollapse(TreeExpansionEvent)
public void treeWillExpand(javax.swing.event.TreeExpansionEvent event)
treeWillExpand
in interface javax.swing.event.TreeWillExpandListener
event
- TreeExpansionEventTreeWillExpandListener.treeWillExpand(TreeExpansionEvent)
public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
e
- PropertyChangeListener.propertyChange(PropertyChangeEvent)
public void valueChanged(javax.swing.event.TreeSelectionEvent event)
valueChanged
in interface javax.swing.event.TreeSelectionListener
event
- TreeSelectionEventTreeSelectionListener.valueChanged(TreeSelectionEvent)
public void setWrapperCellRenderer(javax.swing.tree.TreeCellRenderer newRenderer)
newRenderer
- TreeCellRendererpublic boolean isShowSelectionIcon()
public void setShowSelectionIcon(boolean showSelectionIcon)
showSelectionIcon
- The showSelectionIcon to set.public boolean isCheckBoxOnRootNode()
public void setCheckBoxOnRootNode(boolean checkBoxOnRootNode)
checkBoxOnRootNode
- The checkBoxOnRootNode to set.public boolean isCheckBoxShouldCheckChildren()
public void setCheckBoxShouldCheckChildren(boolean checkBoxShouldCheckChildren)
checkBoxShouldCheckChildren
- The checkBoxShouldCheckChildren to set.public boolean isCheckBoxShouldCheckParents()
public void setCheckBoxShouldCheckParents(boolean checkBoxShouldCheckParents)
checkBoxShouldCheckParents
- The checkBoxShouldCheckParents to set.
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |