|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
com.citra.component.CheckBoxTree
public class CheckBoxTree
CheckBoxTree is a JTree that shows a checkbox for every node in the tree.
The checkbox can be selected/deselected by clicking it with the mouse.
This can also be achieved programmatically by retrieving the CheckBoxTreeSelectionModel
and calling appropriate methods, such as removeSelectionPath or addSelectionPath.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JTree |
---|
JTree.AccessibleJTree, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeSelectionRedirector |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
CHECK_BOX_TREE_SELECTION_MODEL_PROPERTY
Bound property name for CheckBoxTreeSelectionModel . |
protected boolean |
checkBoxesEditable
defines whether the checkboxes can be selected/unselected from the UI |
protected int |
checkBoxGap
the gap between the checkbox and the node's value |
protected CheckBoxTreeSelectionModel |
checkSelectionModel
the selection model for the CheckBoxTree's checked state |
static int |
DEFAULT_CHECKBOX_GAP
the default gap between the checkbox and the node's value |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
CheckBoxTree()
Returns a CheckBoxTree with a sample model. |
|
CheckBoxTree(Hashtable value)
Returns a CheckBoxTree created from a Hashtable which does not display with root. |
|
CheckBoxTree(Object[] value)
Returns a CheckBoxTree with each element of the specified array as the child of a new root node which is not displayed. |
|
CheckBoxTree(TreeModel newModel)
Returns an instance of CheckBoxTree which displays the root node -- the tree is created using the specified data model. |
|
CheckBoxTree(TreeNode root)
Returns a CheckBoxTree with the specified TreeNode as its root, which displays the root node. |
|
CheckBoxTree(TreeNode root,
boolean asksAllowsChildren)
Returns a CheckBoxTree with the specified TreeNode as its root, which displays the root node and which decides whether a node is a leaf node in the specified manner. |
|
CheckBoxTree(Vector value)
Returns a CheckBoxTree with each element of the specified Vector as the child of a new root node which is not displayed. |
Method Summary | |
---|---|
protected CheckBoxTreeSelectionModel |
createCheckBoxSelectionModel()
Returns a new instance of the selection model for the tree node's checked state. |
TreeCellRenderer |
getCellRenderer()
Returns the current TreeCellRenderer
that is rendering each cell. |
boolean |
getCheckBoxesEditable()
Determines whether the check boxes can be selected/deselected from the UI. |
int |
getCheckBoxGap()
Returns the gap between the checkbox and the node's value. |
CheckBoxTreeSelectionModel |
getCheckBoxSelectionModel()
Returns the selection model for the tree node's checked state. |
int |
getCheckBoxState(TreePath path)
Retrieves the state of the check box for a given path. |
boolean |
getPartialSelection()
Determines whether the checkbox tree will use partial selection. |
TreeCellRenderer |
getRealRenderer()
Returns the tree's cell renderer used for rendering the tree after the checkbox part. |
boolean |
isCheckBoxEditable(TreePath path)
Determines whether the check box at the given path is editable. |
boolean |
isCheckBoxEnabled(TreePath path)
Determines whether the check box should be enabled for a given path. |
boolean |
isCheckBoxVisible(TreePath path)
Determines whether the check box should be visible for a given path. |
protected void |
pathSelected(TreePath path,
boolean selected)
Method called after a path has been selected with the mouse. |
protected void |
pathSelecting(TreePath path,
boolean selected)
Method called before a path is selected with the mouse. |
protected void |
processMouseEvent(MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects. |
void |
setCellRenderer(TreeCellRenderer x)
Sets the TreeCellRenderer that will be used to
draw each cell. |
void |
setCheckBoxesEditable(boolean checkBoxesEditable)
Determines whether the check boxes can be selected/deselected from the UI. |
void |
setCheckBoxGap(int checkBoxGap)
Assigns the gap between the checkbox and the node's value. |
void |
setCheckBoxSelectionModel(CheckBoxTreeSelectionModel checkSelectionModel)
Assigns the selection model for the tree node's checked state. |
void |
setModel(TreeModel newModel)
Sets the TreeModel that will provide the data. |
void |
setPartialSelection(boolean partialSelection)
Turns partial selection on/off. |
void |
updateUI()
Notification from the UIManager that the L&F has changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean checkBoxesEditable
protected CheckBoxTreeSelectionModel checkSelectionModel
protected int checkBoxGap
public static final int DEFAULT_CHECKBOX_GAP
public static final String CHECK_BOX_TREE_SELECTION_MODEL_PROPERTY
CheckBoxTreeSelectionModel
.
Constructor Detail |
---|
public CheckBoxTree()
public CheckBoxTree(Object[] value)
public CheckBoxTree(Hashtable value)
public CheckBoxTree(Vector value)
public CheckBoxTree(TreeModel newModel)
public CheckBoxTree(TreeNode root)
public CheckBoxTree(TreeNode root, boolean asksAllowsChildren)
Method Detail |
---|
protected CheckBoxTreeSelectionModel createCheckBoxSelectionModel()
public TreeCellRenderer getCellRenderer()
TreeCellRenderer
that is rendering each cell.
getCellRenderer
in class JTree
TreeCellRenderer
that is rendering each cellpublic boolean getCheckBoxesEditable()
isCheckBoxEditable
method.
public int getCheckBoxGap()
public CheckBoxTreeSelectionModel getCheckBoxSelectionModel()
public int getCheckBoxState(TreePath path)
path
- the path to check
public boolean getPartialSelection()
public TreeCellRenderer getRealRenderer()
public boolean isCheckBoxEditable(TreePath path)
path
- the path to check
public boolean isCheckBoxEnabled(TreePath path)
path
- the path to check
public boolean isCheckBoxVisible(TreePath path)
path
- the path to check
protected void pathSelected(TreePath path, boolean selected)
path
- the path that was selectedselected
- flag indicating whether path was selected or deselectedprotected void pathSelecting(TreePath path, boolean selected)
path
- the path that is selectedselected
- flag indicating whether path is selected or deselectedprotected void processMouseEvent(MouseEvent e)
MouseListener
objects.
This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs:
MouseListener
object is registered
via addMouseListener
.
enableEvents
.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
processMouseEvent
in class Component
e
- the mouse eventMouseEvent
,
MouseListener
,
Component.addMouseListener(java.awt.event.MouseListener)
,
Component.enableEvents(long)
public void setCellRenderer(TreeCellRenderer x)
TreeCellRenderer
that will be used to
draw each cell.
setCellRenderer
in class JTree
x
- the TreeCellRenderer
that is to render each cellpublic void setCheckBoxesEditable(boolean checkBoxesEditable)
isCheckBoxEditable
method.
checkBoxesEditable
- true if editing of checkboxes is allowed, false otherwisepublic void setCheckBoxGap(int checkBoxGap)
checkBoxGap
- the gap in pixels between the checkbox and the node's valuepublic void setCheckBoxSelectionModel(CheckBoxTreeSelectionModel checkSelectionModel)
checkSelectionModel
- the CheckBoxTree's checked state selection model to be assignedpublic void setModel(TreeModel newModel)
TreeModel
that will provide the data.
setModel
in class JTree
newModel
- the TreeModel
that is to provide the datapublic void setPartialSelection(boolean partialSelection)
partialSelection
- true if partial selection is enabled, false otherwisepublic void updateUI()
UIManager
that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager
.
updateUI
in class JTree
JComponent.updateUI()
|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |