public class JXTreeTable extends JXTable
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
!
Modifier and Type | Class and Description |
---|---|
private class |
JXTreeTable.Actions
A small class which dispatches actions.
|
(package private) class |
JXTreeTable.ListToTreeSelectionModelWrapper
ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel
to listen for changes in the ListSelectionModel it maintains.
|
(package private) static class |
JXTreeTable.TreeTableCellRenderer |
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
if outside of node-text.
|
class |
JXTreeTable.TreeTableHackerExt3
A more (or less, depending in pov :-) aggressiv hacker.
|
class |
JXTreeTable.TreeTableHackerExt4
This class extends TreeTableHackerExt instead of TreeTableHackerExt3 so
as to serve as a clue that it is a complete overhaul and looking in
TreeTableHackerExt2 and TreeTableHackerExt3 for methods to change the
behavior will do you no good.
|
class |
JXTreeTable.TreeTableHackerExt5 |
protected static class |
JXTreeTable.TreeTableModelAdapter |
JXTable.BooleanEditor, JXTable.CellEditorRemover, JXTable.GenericEditor, JXTable.NumberEditor, JXTable.TableAdapter
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private boolean |
consumedOnPress |
static String |
DRAG_HACK_FLAG_KEY
Key for clientProperty to decide whether to apply hack around #168-jdnc.
|
static String |
DROP_HACK_FLAG_KEY
Key for clientProperty to decide whether to apply hack around #766-swingx.
|
private TreeTableCellEditor |
hierarchicalEditor
Editor used to edit cells within the
hierarchical column. |
private static Logger |
LOG |
private boolean |
processMouseMotion |
private JXTreeTable.TreeTableCellRenderer |
renderer
Renderer used to render cells within the
hierarchical column. |
private TreeExpansionBroadcaster |
treeExpansionBroadcaster |
private JXTreeTable.TreeTableHacker |
treeTableHacker |
compoundHighlighter, dataAdapter, editorRemover, filteredRowCountChanged, FOCUS_NEXT_COMPONENT, FOCUS_PREVIOUS_COMPONENT, forceRevalidate, HORIZONTALSCROLL_ACTION_COMMAND, isXTableRowHeightSet, MATCH_HIGHLIGHTER, PACKALL_ACTION_COMMAND, PACKSELECTED_ACTION_COMMAND, resetDefaultTableCellRendererHighlighter, searchable, UIPREFIX, USE_DTCR_COLORMEMORY_HACK
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Modifier | Constructor and Description |
---|---|
|
JXTreeTable()
Constructs a JXTreeTable using a
DefaultTreeTableModel . |
private |
JXTreeTable(JXTreeTable.TreeTableCellRenderer renderer)
Constructs a
JXTreeTable using the specified
JXTreeTable.TreeTableCellRenderer . |
|
JXTreeTable(TreeTableModel treeModel)
Constructs a JXTreeTable using the specified
TreeTableModel . |
Modifier and Type | Method and Description |
---|---|
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.
|
private void |
adjustTreeBounds()
Forces the renderer to resize for fitting into hierarchical column.
|
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.
|
void |
columnMarginChanged(ChangeEvent e)
Overridden to support enhanced auto-resize behaviour enabled and
necessary.
|
protected JXTreeTable.TreeTableHacker |
createTreeTableHacker()
Hacking around various issues.
|
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) |
TableCellRenderer |
getCellRenderer(int row,
int column)
Overridden to fix core bug #4614616 (NPE if
TableModel 's
Class for the column is an interface). |
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.
|
private String |
getHierarchicalStringAt(int row)
Returns the String representation of the hierarchical column at the given
row.
|
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. |
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) |
TreeCellRenderer |
getTreeCellRenderer() |
private TreeExpansionBroadcaster |
getTreeExpansionBroadcaster() |
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. here: returns
true if dragEnabled() and a client property with key DRAG_HACK_FLAG_KEY
has a value of boolean true.
|
private void |
init(JXTreeTable.TreeTableCellRenderer renderer)
Initializes this JXTreeTable and permanently binds the specified renderer
to it.
|
private void |
initActions() |
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.
|
protected void |
processMouseMotionEvent(MouseEvent e) |
private int |
realEditingRow()
Returns the actual row that is editing as
getEditingRow
will always return -1. |
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 |
setAutoCreateRowSorter(boolean autoCreateRowSorter)
Overridden to
fix core bug: replaces sorter even if flag doesn't change.
|
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 |
setEnabled(boolean enabled)
Overridden to keep the tree's enabled in synch.
|
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 |
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 |
setRowSorter(RowSorter<? extends TableModel> sorter)
Overridden propagate sort-related properties to the sorter after calling super,
if the given RowSorter is of type SortController.
|
void |
setScrollsOnExpand(boolean scroll)
Sets the value of the
scrollsOnExpand property for the tree
part. |
void |
setSelectionBackground(Color selectionBackground)
Overridden because super throws NPE on null param.
|
void |
setSelectionForeground(Color selectionForeground)
Overridden because super throws NPE on null param.
|
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)
Sets "sortable" property indicating whether or not this table
supports sortable columns.
|
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.
|
protected void |
superSetAutoCreateRowSorter(boolean autoCreateRowSorter)
Hook into super's setAutoCreateRowSorter for use in sub-classes which want to experiment
with tree table sorting/filtering.
|
protected void |
superSetRowSorter(RowSorter<? extends TableModel> sorter)
Hook into super's setRowSorter for use in sub-classes which want to experiment
with tree table sorting/filtering.
|
protected void |
superSetSortable(boolean sortable)
Hook into super's setSortable for use in sub-classes which want to experiment
with tree table sorting/filtering.
|
void |
tableChanged(TableModelEvent e)
Overridden to update internal state related to enhanced functionality and
hack around core bugs.
|
protected void |
updateHierarchicalRendererEditor()
Updates Ui of renderer/editor for the hierarchical column.
|
void |
updateUI()
Additionally updates auto-adjusted row height and highlighters.
|
addHighlighter, adjustComponentOrientation, adminSetRowHeight, columnAdded, columnPropertyChange, columnSelectionChanged, configureColumnControl, configureEnclosingScrollPane, configureSorterProperties, createDefaultColumnControl, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultEditors, createDefaultRenderers, createDefaultRowSorter, createDefaultStringValueRegistry, createDefaultTableHeader, createHighlighterChangeListener, createLinkController, createRolloverProducer, doFind, doLayout, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getColumn, getColumnControl, getColumnCount, getColumnExt, getColumnExt, getColumnFactory, getColumnMargin, getColumns, getColumns, getComponentAdapter, getCompoundHighlighter, getControlsSorterProperties, getEnclosingScrollPane, getHighlighterChangeListener, getHighlighters, getLinkController, getPreferredScrollableViewportSize, getRowFilter, getScrollableTracksViewportWidth, getSearchable, getSelectionMode, getSortController, getSortedColumn, getSortedColumnIndex, getSortOrder, getSortOrder, getSortOrderCycle, getSortsOnUpdates, getStringValueRegistry, getUIString, getUIString, getVisibleColumnCount, getVisibleRowCount, hasSortController, initializeColumnPreferredWidth, initializeColumnWidths, isAutoStartEditOnKeyStroke, isCellEditable, isColumnControlVisible, isDataChanged, isEditable, isFocusCycleRoot, isHorizontalScrollEnabled, isRolloverEnabled, isSortable, isStructureChanged, isTerminateEditOnFocusLost, isUpdate, packAll, packColumn, packColumn, packSelected, packTable, postprocessModelChange, postprocessSorterChanged, prepareEditor, prepareRenderer, preprocessModelChange, removeColumnControlFromCorners, removeEditor, removeHighlighter, removeNotify, resetDefaultTableCellRendererColors, resetSortOrder, rowAtPoint, scrollCellToVisible, scrollColumnToVisible, scrollRowToVisible, setAutoResizeMode, setAutoStartEditOnKeyStroke, setColumnControl, setColumnControlVisible, setColumnFactory, setColumnMargin, setColumnModel, setColumnSequence, setComponentOrientation, setDefaultRenderer, setEditable, setFillsViewportHeight, setGridColor, setHighlighters, setHorizontalScrollEnabled, setLocale, setPreferredScrollableViewportSize, setRolloverEnabled, setRowFilter, setSearchable, setShowGrid, setShowGrid, setSortOrder, setSortOrder, setSortOrderCycle, setSortsOnUpdates, setTerminateEditOnFocusLost, setValueAt, setVisibleColumnCount, setVisibleRowCount, sorterChanged, toggleSortOrder, toggleSortOrder, transferFocus, transferFocusBackward, unconfigureColumnControl, unconfigureEnclosingScrollPane, updateColumnControlUI, updateColumnUI, updateHighlighterUI, updateHorizontalAction, updateLocaleActionState, updateLocaleState, updateRowHeightUI
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, columnAtPoint, columnMoved, columnRemoved, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultDataModel, createDefaultSelectionModel, createScrollPaneForTable, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoResizeMode, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeRowSelectionInterval, resizeAndRepaint, selectAll, setAutoCreateColumnsFromModel, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setIntercellSpacing, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionModel, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, sizeColumnsToFit, valueChanged
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
columnMoved, columnRemoved
public static final String DRAG_HACK_FLAG_KEY
public static final String DROP_HACK_FLAG_KEY
private JXTreeTable.TreeTableCellRenderer renderer
hierarchical
column.
renderer extends JXTree and implements TableCellRendererprivate TreeTableCellEditor hierarchicalEditor
hierarchical
column.private JXTreeTable.TreeTableHacker treeTableHacker
private boolean consumedOnPress
private TreeExpansionBroadcaster treeExpansionBroadcaster
private boolean processMouseMotion
public JXTreeTable()
DefaultTreeTableModel
.public JXTreeTable(TreeTableModel treeModel)
TreeTableModel
.treeModel
- model for the JXTreeTableprivate JXTreeTable(JXTreeTable.TreeTableCellRenderer renderer)
JXTreeTable
using the specified
JXTreeTable.TreeTableCellRenderer
.renderer
- cell renderer for the tree portion of this JXTreeTable
instance.private void init(JXTreeTable.TreeTableCellRenderer renderer)
renderer
- private tree/renderer permanently and exclusively bound
to this JXTreeTable.private void initActions()
public void setSortable(boolean sortable)
sortable
is true
then sorting will be enabled on all columns whose sortable
property is true
. If sortable
is
false
then sorting will be disabled for all columns,
regardless of each column's individual sorting
property. The
default is true
. Note: as of post-1.0 this property is propagated to the SortController if controlsSorterProperties is true. Whether or not a change triggers a re-sort is up to either the concrete controller implementation (the default doesn't) or client code. This behaviour is different from old SwingX style sorting.
Overridden to do nothing. TreeTable is not sortable because there is no equivalent to RowSorter (which is targeted to linear structures) for hierarchical data.
setSortable
in class JXTable
sortable
- boolean indicating whether or not this table supports
sortable columnsJXTable.getControlsSorterProperties()
public void setAutoCreateRowSorter(boolean autoCreateRowSorter)
Overridden to
Overridden to do nothing. TreeTable is not sortable because there is no equivalent to RowSorter (which is targeted to linear structures) for hierarchical data.
setAutoCreateRowSorter
in class JXTable
public void setRowSorter(RowSorter<? extends TableModel> sorter)
Overridden propagate sort-related properties to the sorter after calling super, if the given RowSorter is of type SortController. Does nothing additional otherwise.
Overridden to do nothing. TreeTable is not sortable because there is no equivalent to RowSorter (which is targeted to linear structures) for hierarchical data.
setRowSorter
in class JXTable
protected void superSetAutoCreateRowSorter(boolean autoCreateRowSorter)
NOTE: While subclasses may use this method to allow access to super that usage alone will not magically turn sorting/filtering on! They have to implement an appropriate RowSorter/SortController as well. This is merely a hook to hang themselves, as requested in Issue #479-swingx
autoCreateRowSorter
- protected void superSetSortable(boolean sortable)
NOTE: While subclasses may use this method to allow access to super that usage alone will not magically turn sorting/filtering on! They have to implement an appropriate RowSorter/SortController as well. This is merely a hook to hang themselves, as requested in Issue #479-swingx
sortable
- protected void superSetRowSorter(RowSorter<? extends TableModel> sorter)
NOTE: While subclasses may use this method to allow access to super that usage alone will not magically turn sorting/filtering on! They have to implement an appropriate RowSorter/SortController as well. This is merely a hook to hang themselves, as requested in Issue #479-swingx
sorter
- public void setEnabled(boolean enabled)
Overridden to keep the tree's enabled in synch.
setEnabled
in class JComponent
public void setSelectionBackground(Color selectionBackground)
Overridden because super throws NPE on null param.
Overridden to keep the tree's selectionBackground in synch.
setSelectionBackground
in class JXTable
public void setSelectionForeground(Color selectionForeground)
Overridden because super throws NPE on null param.
Overridden to keep the tree's selectionForeground in synch.
setSelectionForeground
in class JXTable
public boolean editCellAt(int row, int column, EventObject e)
Additionally, there is tricksery involved to expand/collapse the nodes.
overridden to install a custom editor remover.
editCellAt
in class JXTable
protected void processMouseEvent(MouseEvent e)
processMouseEvent
in class JComponent
protected JXTreeTable.TreeTableHacker getTreeTableHacker()
protected JXTreeTable.TreeTableHacker createTreeTableHacker()
protected void processMouseMotionEvent(MouseEvent e)
processMouseMotionEvent
in class JComponent
protected boolean hackAroundDragEnabled(MouseEvent me)
Note: this is updated for 1.6, as the intermediate system property for enabled drag support is useless now (it's the default)
me
- the mouseEvent that triggered a editCellAtpublic int getEditingRow()
getEditingRow
in class JTable
private int realEditingRow()
getEditingRow
will always return -1.public void setTreeTableModel(TreeTableModel treeModel)
TreeTableModel
. The same data model
may be shared by any number of JXTreeTable instances.treeModel
- data model for this JXTreeTablepublic TreeTableModel getTreeTableModel()
public final void setModel(TableModel tableModel)
Overrides superclass version to make sure that the specified
TableModel
is compatible with JXTreeTable before
invoking the inherited version.
Because JXTreeTable internally adapts an
TreeTableModel
to make it a compatible
TableModel, this method should never be called directly. Use
setTreeTableModel
instead.
While it is possible to obtain a reference to this adapted
version of the TableModel by calling JTable.getModel()
,
any attempt to call setModel() with that adapter will fail because
the adapter might have been bound to a different JXTreeTable instance. If
you want to extract the underlying TreeTableModel, which, by the way,
can be shared, use getTreeTableModel
instead
setModel
in class JXTable
tableModel
- must be a TreeTableModelAdapterIllegalArgumentException
- if the specified tableModel is not an
instance of TreeTableModelAdapterpublic void tableChanged(TableModelEvent e)
JXTable
Overridden to update internal state related to enhanced functionality and hack around core bugs.
tableChanged
in interface TableModelListener
tableChanged
in class JXTable
public final void setRowHeight(int row, int rowHeight)
setRowHeight
in class JTable
row
- ignoredrowHeight
- ignoredUnsupportedOperationException
- because variable height rows are
not supportedpublic void setRowHeight(int rowHeight)
setRowHeight
in class JXTable
rowHeight
- height of a row.JXTable.isXTableRowHeightSet
protected void adjustTreeRowHeight(int tableRowHeight)
tableRowHeight
- height of a row.protected void adjustTableRowHeight(int treeRowHeight)
treeRowHeight
- height of a row.public void columnMarginChanged(ChangeEvent e)
Overridden to support enhanced auto-resize behaviour enabled and necessary.
Overridden to adjust the renderer's size.
columnMarginChanged
in interface TableColumnModelListener
columnMarginChanged
in class JXTable
JXTable.setHorizontalScrollEnabled(boolean)
private void adjustTreeBounds()
public void setSelectionMode(int mode)
Overridden to ensure that private renderer state is kept in sync with the state of the component. Calls the inherited version after performing the necessary synchronization. If you override this method, make sure you call this version from your version of this method.
This version maps the selection mode used by the renderer to match the selection mode specified for the table. Specifically, the modes are mapped as follows:
ListSelectionModel.SINGLE_INTERVAL_SELECTION: TreeSelectionModel.CONTIGUOUS_TREE_SELECTION; ListSelectionModel.MULTIPLE_INTERVAL_SELECTION: TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION; any other (default): TreeSelectionModel.SINGLE_TREE_SELECTION;
setSelectionMode
in class JTable
mode
- any of the table selection modespublic Component prepareRenderer(TableCellRenderer renderer, int row, int column)
Component
used as a stamp to render
the specified cell. Overrides superclass version to provide support for
cell decorators.
Adjusts component orientation (guaranteed to happen before applying Highlighters).
Per-column highlighters contained in
TableColumnExt.getHighlighters()
are applied to the renderer
after the table highlighters.
TODO kgs: interaction of search highlighter and column highlighters
Note: DefaultTableCellRenderer and subclasses require a hack to play
nicely with Highlighters because it has an internal "color memory" in
setForeground/setBackground. The hack is applied in
resetDefaultTableCellRendererColors
which is called after
super.prepareRenderer and before applying the Highlighters. The method is
called always and for all renderers.
Overridden to decorate the tree's renderer after calling super. At that point, it is only the tree itself that has been decorated.
prepareRenderer
in class JXTable
renderer
- the TableCellRenderer
to preparerow
- the row of the cell to render, where 0 is the first rowcolumn
- the column of the cell to render, where 0 is the first columnComponent
used as a stamp to render the specified cellapplyRenderer(Component, ComponentAdapter)
protected Component applyRenderer(Component component, ComponentAdapter adapter)
Note: this is legacy glue if the treeCellRenderer is of type DefaultTreeCellRenderer. In that case the renderer's background/foreground/Non/Selection colors are set to the tree's background/foreground depending on the adapter's selection state. Does nothing if the treeCellRenderer is backed by a ComponentProvider.
component
- the rendering componentadapter
- component data adapterNullPointerException
- if the specified component or adapter is
nullpublic void setTreeCellRenderer(TreeCellRenderer cellRenderer)
cellRenderer
- to use for rendering tree cells.public TreeCellRenderer getTreeCellRenderer()
public String getToolTipText(MouseEvent event)
getToolTipText
in class JTable
public void setCollapsedIcon(Icon icon)
icon
- to use for rendering collapsed nodesJXTree.setCollapsedIcon(Icon)
public void setExpandedIcon(Icon icon)
icon
- to use for rendering expanded nodesJXTree.setExpandedIcon(Icon)
public void setOpenIcon(Icon icon)
icon
- to use for rendering open nodesJXTree.setOpenIcon(Icon)
public void setClosedIcon(Icon icon)
icon
- to use for rendering closed nodesJXTree.setClosedIcon(Icon)
public void setLeafIcon(Icon icon)
icon
- to use for rendering leaf nodesJXTree.setLeafIcon(Icon)
public void setOverwriteRendererIcons(boolean overwrite)
The default value is false.
overwrite
- a boolean to indicate if the per-tree Icons should
be copied to the new renderer on setTreeCellRenderer.isOverwriteRendererIcons()
,
setLeafIcon(Icon)
,
setOpenIcon(Icon)
,
setClosedIcon(Icon)
,
JXTree.setOverwriteRendererIcons(boolean)
public boolean isOverwriteRendererIcons()
setOverwriteRendererIcons(boolean)
,
setLeafIcon(Icon)
,
setOpenIcon(Icon)
,
setClosedIcon(Icon)
,
JXTree.isOverwriteRendererIcons()
public void clearSelection()
clearSelection
in class JTable
public void collapseAll()
public void expandAll()
public void collapsePath(TreePath path)
path
- path of the node to collapsepublic void expandPath(TreePath path)
path
- path of the node to expandpublic void scrollPathToVisible(TreePath path)
JTree
is contained in a JScrollPane
.
(doc copied from JTree)
PENDING: JW - where exactly do we want to scroll? Here: the scroll
is in vertical direction only. Might need to show the tree column?path
- the TreePath
identifying the node to
bring into viewpublic void collapseRow(int row)
public void expandRow(int row)
public boolean isVisible(TreePath path)
public boolean isExpanded(TreePath path)
path
- pathpublic boolean isExpanded(int row)
row
- rowpublic boolean isCollapsed(TreePath path)
path
- pathpublic boolean isCollapsed(int row)
row
- rowpublic Enumeration<?> getExpandedDescendants(TreePath parent)
Enumeration
of the descendants of the
path parent
that
are currently expanded. If parent
is not currently
expanded, this will return null
.
If you expand/collapse nodes while
iterating over the returned Enumeration
this may not return all
the expanded paths, or may return paths that are no longer expanded.parent
- the path which is to be examinedEnumeration
of the descendents of
parent
, or null
if
parent
is not currently expandedpublic TreePath getPathForLocation(int x, int y)
x
- x valuey
- y valueTreePath
for the givern location.public TreePath getPathForRow(int row)
row
- TreePath
for the given row.public int getRowForPath(TreePath path)
path
- TreePath
.public void setRootVisible(boolean visible)
visible
- true, if the root node is visible; false, otherwisepublic boolean isRootVisible()
public void setScrollsOnExpand(boolean scroll)
scrollsOnExpand
property for the tree
part. This property specifies whether the expanded paths should be scrolled
into view. In a look and feel in which a tree might not need to scroll
when expanded, this property may be ignored.scroll
- true, if expanded paths should be scrolled into view;
false, otherwisepublic boolean getScrollsOnExpand()
scrollsOnExpand
property.scrollsOnExpand
propertypublic void setShowsRootHandles(boolean visible)
showsRootHandles
property for the tree
part. This property specifies whether the node handles should be displayed.
If handles are not supported by a particular look and feel, this property
may be ignored.visible
- true, if root handles should be shown; false, otherwisepublic boolean getShowsRootHandles()
showsRootHandles
property.showsRootHandles
propertypublic void setExpandsSelectedPaths(boolean expand)
expandsSelectedPaths
property for the tree
part. This property specifies whether the selected paths should be expanded.expand
- true, if selected paths should be expanded; false, otherwisepublic boolean getExpandsSelectedPaths()
expandsSelectedPaths
property.expandsSelectedPaths
propertypublic int getToggleClickCount()
public void setToggleClickCount(int clickCount)
clickCount
- the number of clicks required to expand/collapse a node.public boolean isLargeModel()
setLargeModel(boolean)
public void setLargeModel(boolean newValue)
NOTE: this method is exposed for completeness - currently it's not recommended to use a large model because there are some issues (not yet fully understood), namely issue #25-swingx, and probably #270-swingx.
newValue
- true to suggest a large model to the UIpublic void addTreeExpansionListener(TreeExpansionListener tel)
TreeExpansion
events.tel
- a TreeExpansionListener that will be notified
when a tree node is expanded or collapsedprivate TreeExpansionBroadcaster getTreeExpansionBroadcaster()
public void removeTreeExpansionListener(TreeExpansionListener tel)
TreeExpansion
events.tel
- the TreeExpansionListener
to removepublic void addTreeSelectionListener(TreeSelectionListener tsl)
TreeSelection
events.
TODO (JW): redirect event source to this.tsl
- a TreeSelectionListener that will be notified
when a tree node is selected or deselectedpublic void removeTreeSelectionListener(TreeSelectionListener tsl)
TreeSelection
events.tsl
- the TreeSelectionListener
to removepublic void addTreeWillExpandListener(TreeWillExpandListener tel)
TreeWillExpand
events.
TODO (JW): redirect event source to this.tel
- a TreeWillExpandListener that will be notified
when a tree node will be expanded or collapsedpublic void removeTreeWillExpandListener(TreeWillExpandListener tel)
TreeWillExpand
events.tel
- the TreeWillExpandListener
to removepublic TreeSelectionModel getTreeSelectionModel()
public void sizeColumnsToFit(int resizingColumn)
getEditingRow
returns
-1, and therefore doesn't automaticly resize the editor for us.sizeColumnsToFit
in class JTable
public boolean isHierarchical(int column)
column
- zero-based index of the column in view coordinatesIllegalArgumentException
- if the column is less than 0 or greater than or equal to the
column countpublic int getHierarchicalColumn()
public TableCellRenderer getCellRenderer(int row, int column)
Overridden to fix core bug #4614616 (NPE if TableModel
's
Class
for the column is an interface). This method
guarantees to always return a not null
value. Returns the
default renderer for Object
if super returns
null
.
Note: The lookup strategy for is unchanged compared to super. Subclasses which override this with a different lookup strategy are strongly advised to implement a custom StringValueRegistry with that lookup strategy to keep the WYSIWYM in SwingX.
getCellRenderer
in class JXTable
public TableCellEditor getCellEditor(int row, int column)
getCellEditor
in class JTable
public void updateUI()
JXTable
Additionally updates auto-adjusted row height and highlighters.
Another of the override motivation is to fix core issue (?? ID): super fails to update all renderers/editors.
protected void updateHierarchicalRendererEditor()
public String getStringAt(int row, int column)
Overridden to message the tree directly if the column is the view index of the hierarchical column.
PENDING JW: revisit once we switch to really using a table renderer. As is, it's a quick fix for #821-swingx: string rep for hierarchical column incorrect.
getStringAt
in class JXTable
row
- the row index of the cell in view coordinatescolumn
- the column index of the cell in view coordinates.private String getHierarchicalStringAt(int row)
row
- the row index in view coordinatesgetStringAt(int, int)
protected ComponentAdapter getComponentAdapter()
getComponentAdapter
in class JXTable
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses