|
||||||||||
| 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.JTable
org.jdesktop.swingx.JXTable
org.jdesktop.swingx.JXTreeTable
public class JXTreeTable
JXTreeTable is a specialized table
consisting of a single column in which to display hierarchical data, and any
number of other columns in which to display regular data. The interface for
the data model used by a JXTreeTable is
TreeTableModel. It extends the
TreeModel interface to allow access to cell data by
column indices within each node of the tree hierarchy.
The most straightforward way create and use a JXTreeTable, is to
first create a suitable data model for it, and pass that to a
JXTreeTable constructor, as shown below:
TreeTableModel treeTableModel = new FileSystemModel(); // any TreeTableModel JXTreeTable treeTable = new JXTreeTable(treeTableModel); JScrollPane scrollpane = new JScrollPane(treeTable);See
JTable for an explanation of why putting the treetable
inside a scroll pane is necessary.
A single treetable model instance may be shared among more than one
JXTreeTable instances. To access the treetable model, always call
getTreeTableModel and
setTreeTableModel.
JXTreeTable wraps the supplied treetable model inside a private
adapter class to adapt it to a TableModel. Although
the model adapter is accessible through the getModel method, you
should avoid accessing and manipulating it in any way. In particular, each
model adapter instance is tightly bound to a single table instance, and any
attempt to share it with another table (for example, by calling
setModel)
will throw an IllegalArgumentException!
| Nested Class Summary | |
|---|---|
protected static class |
JXTreeTable.TreeTableDataAdapter
|
class |
JXTreeTable.TreeTableHacker
Temporary class to have all the hacking at one place. |
class |
JXTreeTable.TreeTableHackerExt
Note: currently this class looks a bit funny (only overriding the hit decision method). |
class |
JXTreeTable.TreeTableHackerExt2
Patch for #471-swingx: no selection on click in hierarchical column outside of node-text. |
protected static class |
JXTreeTable.TreeTableModelAdapter
|
| Nested classes/interfaces inherited from class org.jdesktop.swingx.JXTable |
|---|
JXTable.BooleanEditor, JXTable.GenericEditor, JXTable.NumberEditor, JXTable.TableAdapter, JXTable.TableRolloverController<T extends JTable>, JXTable.TableSearchable |
| Nested classes/interfaces inherited from class javax.swing.JTable |
|---|
JTable.AccessibleJTable, JTable.PrintMode |
| 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 |
DRAG_HACK_FLAG_KEY
Key for clientProperty to decide whether to apply hack around #168-jdnc. |
| Fields inherited from class org.jdesktop.swingx.JXTable |
|---|
compoundHighlighter, dataAdapter, editorRemover, filters, FOCUS_NEXT_COMPONENT, FOCUS_PREVIOUS_COMPONENT, HORIZONTALSCROLL_ACTION_COMMAND, isXTableRowHeightSet, MATCH_HIGHLIGHTER, PACKALL_ACTION_COMMAND, PACKSELECTED_ACTION_COMMAND, resetDefaultTableCellRendererHighlighter, searchable, selectionMapper, UIPREFIX, USE_DTCR_COLORMEMORY_HACK |
| 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 | |
|---|---|
JXTreeTable()
Constructs a JXTreeTable using a DefaultTreeTableModel. |
|
JXTreeTable(TreeTableModel treeModel)
Constructs a JXTreeTable using the specified TreeTableModel. |
|
| Method Summary | |
|---|---|
void |
addTreeExpansionListener(TreeExpansionListener tel)
Adds a listener for TreeExpansion events. |
void |
addTreeSelectionListener(TreeSelectionListener tsl)
Adds a listener for TreeSelection events. |
void |
addTreeWillExpandListener(TreeWillExpandListener tel)
Adds a listener for TreeWillExpand events. |
protected void |
adjustTableRowHeight(int treeRowHeight)
Forwards treeRowHeight to table. |
protected void |
adjustTreeRowHeight(int tableRowHeight)
Forwards tableRowHeight to tree. |
protected Component |
applyRenderer(Component component,
ComponentAdapter adapter)
Performs configuration of the tree's renderer if the adapter's column is the hierarchical column, does nothing otherwise. |
void |
clearSelection()
Overridden to ensure that private renderer state is kept in sync with the state of the component. |
void |
collapseAll()
Collapses all nodes in the treetable. |
void |
collapsePath(TreePath path)
Collapses the node at the specified path in the treetable. |
void |
collapseRow(int row)
Collapses the row in the treetable. |
protected SelectionMapper |
createSelectionMapper()
Fix for #745-swingx: remove static selectionMaper. |
protected JXTreeTable.TreeTableHacker |
createTreeTableHacker()
|
boolean |
editCellAt(int row,
int column,
EventObject e)
Overriden to invoke repaint for the particular location if the column contains the tree. |
void |
expandAll()
Expands all nodes in the treetable. |
void |
expandPath(TreePath path)
Expands the the node at the specified path in the treetable. |
void |
expandRow(int row)
Expands the specified row in the treetable. |
TableCellEditor |
getCellEditor(int row,
int column)
Returns an appropriate editor for the cell specified by row and column. |
TableCellRenderer |
getCellRenderer(int row,
int column)
Returns an appropriate renderer for the cell specified by this row and column. If the TableColumn for this column has a non-null
renderer, returns that. If not, finds the class of the data in
this column (using getColumnClass)
and returns the default renderer for this type of data.
Note: Throughout the table package, the internal implementations always use this method to provide renderers so that this default behavior can be safely overridden by a subclass. |
protected ComponentAdapter |
getComponentAdapter()
Returns the adapter that knows how to access the component data model. |
int |
getEditingRow()
Overridden to provide a workaround for BasicTableUI anomaly. |
Enumeration<?> |
getExpandedDescendants(TreePath parent)
Returns an Enumeration of the descendants of the
path parent that
are currently expanded. |
boolean |
getExpandsSelectedPaths()
Returns the value of the expandsSelectedPaths property. |
int |
getHierarchicalColumn()
Returns the index of the hierarchical column. |
TreePath |
getPathForLocation(int x,
int y)
Returns the TreePath for a given x,y location. |
TreePath |
getPathForRow(int row)
Returns the TreePath for a given row. |
int |
getRowForPath(TreePath path)
Returns the row for a given TreePath. |
boolean |
getScrollsOnExpand()
Returns the value of the scrollsOnExpand property. |
SelectionMapper |
getSelectionMapper()
Overridden to return a do-nothing mapper. |
boolean |
getShowsRootHandles()
Returns the value of the showsRootHandles property. |
String |
getStringAt(int row,
int column)
Returns the string representation of the cell value at the given position. |
int |
getToggleClickCount()
Returns the number of mouse clicks needed to expand or close a node. |
String |
getToolTipText(MouseEvent event)
Overrides JComponent's getToolTipText
method in order to allow the renderer's tips to be used
if it has text set. |
TreeCellRenderer |
getTreeCellRenderer()
|
TreeSelectionModel |
getTreeSelectionModel()
Returns the selection model for the tree portion of the this treetable. |
protected JXTreeTable.TreeTableHacker |
getTreeTableHacker()
|
TreeTableModel |
getTreeTableModel()
Returns the underlying TreeTableModel for this JXTreeTable. |
protected boolean |
hackAroundDragEnabled(MouseEvent me)
decides whether we want to apply the hack for #168-jdnc. |
boolean |
isCollapsed(int row)
Returns true if the node at the specified display row is collapsed. |
boolean |
isCollapsed(TreePath path)
Returns true if the node identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed. |
boolean |
isExpanded(int row)
Returns true if the node at the specified display row is currently expanded. |
boolean |
isExpanded(TreePath path)
Returns true if the node identified by path is currently expanded. |
boolean |
isHierarchical(int column)
Determines if the specified column is defined as the hierarchical column. |
boolean |
isLargeModel()
Returns true if the tree is configured for a large model. |
boolean |
isOverwriteRendererIcons()
Returns a boolean indicating whether the per-tree icons should be copied to the renderer on setTreeCellRenderer. |
boolean |
isRootVisible()
Returns true if the root node of the tree is displayed. |
boolean |
isVisible(TreePath path)
Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded. |
Component |
prepareRenderer(TableCellRenderer renderer,
int row,
int column)
Returns the decorated Component used as a stamp to render
the specified cell. |
protected void |
processMouseEvent(MouseEvent e)
Overridden to enable hit handle detection a mouseEvent which triggered a expand/collapse. |
void |
removeTreeExpansionListener(TreeExpansionListener tel)
Removes a listener for TreeExpansion events. |
void |
removeTreeSelectionListener(TreeSelectionListener tsl)
Removes a listener for TreeSelection events. |
void |
removeTreeWillExpandListener(TreeWillExpandListener tel)
Removes a listener for TreeWillExpand events. |
void |
scrollPathToVisible(TreePath path)
Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed. |
void |
setClosedIcon(Icon icon)
Sets the specified icon as the icon to use for rendering closed container nodes. |
void |
setCollapsedIcon(Icon icon)
Sets the specified icon as the icon to use for rendering collapsed nodes. |
void |
setExpandedIcon(Icon icon)
Sets the specified icon as the icon to use for rendering expanded nodes. |
void |
setExpandsSelectedPaths(boolean expand)
Sets the value of the expandsSelectedPaths property for the tree
part. |
void |
setFilters(FilterPipeline pipeline)
overridden to do nothing. |
void |
setLargeModel(boolean newValue)
Specifies whether the UI should use a large model. |
void |
setLeafIcon(Icon icon)
Sets the specified icon as the icon to use for rendering leaf nodes. |
void |
setModel(TableModel tableModel)
Overrides superclass version to make sure that the specified TableModel is compatible with JXTreeTable before
invoking the inherited version. |
void |
setOpenIcon(Icon icon)
Sets the specified icon as the icon to use for rendering open container nodes. |
void |
setOverwriteRendererIcons(boolean overwrite)
Property to control whether per-tree icons should be copied to the renderer on setTreeCellRenderer. |
void |
setRootVisible(boolean visible)
Determines whether or not the root node from the TreeModel is visible. |
void |
setRowHeight(int rowHeight)
Sets the row height for this JXTreeTable and forwards the row height to the renderering tree. |
void |
setRowHeight(int row,
int rowHeight)
Throws UnsupportedOperationException because variable height rows are not supported. |
void |
setScrollsOnExpand(boolean scroll)
Sets the value of the scrollsOnExpand property for the tree
part. |
void |
setSelectionMode(int mode)
Overridden to ensure that private renderer state is kept in sync with the state of the component. |
void |
setShowsRootHandles(boolean visible)
Sets the value of the showsRootHandles property for the tree
part. |
void |
setSortable(boolean sortable)
overridden to do nothing. |
void |
setToggleClickCount(int clickCount)
Sets the number of mouse clicks before a node will expand or close. |
void |
setTreeCellRenderer(TreeCellRenderer cellRenderer)
Sets the specified TreeCellRenderer as the Tree cell renderer. |
void |
setTreeTableModel(TreeTableModel treeModel)
Sets the data model for this JXTreeTable to the specified TreeTableModel. |
void |
sizeColumnsToFit(int resizingColumn)
Overriden to invoke supers implementation, and then, if the receiver is editing a Tree column, the editors bounds is reset. |
void |
tableChanged(TableModelEvent e)
additionally updates filtered state. |