|
||||||||||
| 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.swing.JXTable
org.jdesktop.swing.JTreeTable
JTreeTable 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 JTreeTable 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 JTreeTable, is to
first create a suitable data model for it, and pass that to a
JTreeTable constructor, as shown below:
TreeTableModel treeTableModel = new FileSystemModel(); // any TreeTableModel JTreeTable treeTable = new JTreeTable(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
JTreeTable instances. To access the treetable model, always call
getTreeTableModel and
setTreeTableModel.
JTreeTable 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 |
| Nested classes inherited from class javax.swing.JTable |
JTable.AccessibleJTable |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
| Fields inherited from class org.jdesktop.swing.JXTable |
filters, highlighters, PRINT_MODE_FIT_WIDTH, PRINT_MODE_NORMAL, sorter, TRACE |
| 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 | |
JTreeTable()
Constructs a JTreeTable using a DefaultTreeTableModel. |
|
JTreeTable(TreeTableModel treeModel)
Constructs a JTreeTable using the specified TreeTableModel. |
|
| Method Summary | |
protected Component |
applyRenderer(Component component,
ComponentAdapter adapter)
Performs necessary housekeeping before the renderer is actually applied. |
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. |
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. |
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. |
boolean |
getExpandsSelectedPaths()
Returns the value of the expandsSelectedPaths property. |
boolean |
getScrollsOnExpand()
Returns the value of the scrollsOnExpand property. |
boolean |
getShowsRootHandles()
Returns the value of the showsRootHandles property. |
TreeTableModel |
getTreeTableModel()
Returns the underlying TreeTableModel for this JTreeTable. |
boolean |
isHierarchical(int column)
Determines if the specified column contains hierarchical nodes. |
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)
Overrides superclass version to provide support for cell decorators. |
protected void |
resetSorter()
Overrides superclass version to be a no-op. |
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 |
setColumnMargin(int columnMargin)
Sets the margin between columns. |
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 |
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 JTreeTable before
invoking the inherited version. |
void |
setOpenIcon(Icon icon)
Sets the specified icon as the icon to use for rendering open container nodes. |
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 JTreeTable. |
void |
setRowHeight(int row,
int rowHeight)
Throws UnsupportedOperationException because variable height rows are not supported. |
void |
setRowMargin(int rowMargin)
Overridden to ensure that private renderer state is kept in sync with the state of the component. |
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 |
setShowHorizontalLines(boolean show)
Sets whether the table draws horizontal lines between cells. |
void |
setShowsRootHandles(boolean visible)
Sets the value of the showsRootHandles property for the tree
part. |
void |
setShowVerticalLines(boolean show)
Sets whether the table draws vertical lines between cells. |
protected void |
setSorter(int columnIndex)
Overrides superclass version to be a no-op. |
void |
setTreeTableModel(TreeTableModel treeModel)
Sets the data model for this JTreeTable 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 |
updateUI()
Overridden to message super and forward the method to the tree. |
| Methods inherited from class org.jdesktop.swing.JXTable |
contentsChanged, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnsFromModel, createDefaultDataModel, getColumnExt, getColumnExt, getColumnMargin, getColumns, getFilters, getHighlighters, getPreferredScrollableViewportSize, getPrintable, getRowCount, getSelectionMode, getSorter, getValueAt, getVisibleRowCount, init, isCellEditable, isPrinting, print, print, print, print, removeColumns, search, search, search, search, search, setFilters, setHighlighters, setTableHeader, setValueAt, setVisibleRowCount, tableChanged |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public JTreeTable()
DefaultTreeTableModel.
public JTreeTable(TreeTableModel treeModel)
TreeTableModel.
treeModel - model for the JTreeTable| Method Detail |
protected void resetSorter()
resetSorter in class JXTableprotected void setSorter(int columnIndex)
setSorter in class JXTablepublic void setShowHorizontalLines(boolean show)
Sets whether the table draws horizontal lines between cells. It draws
the lines if show is true; otherwise it doesn't. By default,
a table draws the lines.
If you want the lines to be drawn, make sure that the row margin or horizontal intercell spacing is greater than zero.
show - true, if horizontal lines should be drawn; false, if lines
should not be drawngetShowHorizontalLines,
setRowMargin,
setIntercellSpacingpublic void setShowVerticalLines(boolean show)
Sets whether the table draws vertical lines between cells. It draws
the lines if show is true; otherwise it doesn't. By default,
a table draws the lines.
If you want the lines to be drawn, make sure that the column margin or vertical intercell spacing is greater than zero.
show - true, if vertical lines should be drawn; false, if lines
should not be drawngetShowVerticalLines,
setColumnMargin,
setInte