Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.treetable
Class TreeTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by com.citra.table.AdvancedJTable
                      extended by com.citra.treetable.TreeTable
All Implemented Interfaces:
VetoableTableColumnModelListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
DirectoryTreeTable

public class TreeTable
extends AdvancedJTable

TreeTable works exactly the same as AdvancedJTable, with the only difference that this component is capable of grouping several similar rows of a table in a single row by using a JTree component.

TreeTable uses a TreeTableModelAdapter as its TableModel. An IllegalArgumentException will be thrown if one tries to set a TableModel that is not an instance of the TreeTableModelAdapter class.

A TreeTable component can be created by supplying a TreeTableModel. TreeTable takes this parameter and constructs a TreeTableModelAdapter, which it uses as its TableModel.

The view of the TreeTable can be easily customized. In fact, the getCellRenderer method has been overriden so that aggregate rows can have their own renderer. The renderer to use in those cases can be assigned with setDefaultAggregateRenderer. The getAggregateCellRenderer method can also be overriden to provide a similar behaviour. TreeTable will install, by default, aggregate renderers for the basic classes (String, Object, Date, Boolean and Number). see createDefaultRenderers

A reference to the TreeTableModel can be taken with:

TreeTableModelAdapter adapter = (TreeTableModelAdapter) treetable.getModel();
TreeTableModel model = adapter.getTreeTableModel();

See Also:
Serialized Form

Nested Class Summary
 class TreeTable.DefaultTreeSpanModel
          DefaultTreeSpanModel uses the treetable's model in order to return a cell span for every header row.
 class TreeTable.DefaultTreeStyleModel
          DefaultTreeStyleModel is the TreeTable's style model.
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable
 
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
protected  Hashtable defaultAggregateRenderers
          A table of objects that are responsible for drawing the cells of aggregate rows, indexed by class.
protected  int treeColumn
          the column containing the tree
 
Fields inherited from class com.citra.table.AdvancedJTable
cellResizer, COMMIT_EDIT, CONTINUE_EDIT, DISCARD_EDIT, editMode, isFirstColumnFixed, nonContiguousCellSelection, nonContiguousSelectionModel, rowHeader, scroller, showRowHeader, spanDrawer, styleModel, tableAssistant, tableReorder, viewableResizer
 
Fields inherited from class javax.swing.JTable
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
 
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
TreeTable()
          Constructs a TreeTable object with the table's model being returned by the createDefaultDataModel method.
TreeTable(TreeTableModel model)
          Constructs a TreeTable object having model as the TreeTableModelAdapter's treetable model.
TreeTable(TreeTableModelAdapter adapter)
          Constructs a TreeTable object having adapter as the table's model.
 
Method Summary
 void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
          Updates the selection models of the table, depending on the state of the two flags: toggle and extend.
protected  TableModel createDefaultDataModel()
          Creates a new instance of a TreeTableModelAdapter.
protected  void createDefaultRenderers()
          TreeTable installs a DefaultTreeTableRenderer for each of the basic classes (String, Object, Date, Boolean and Number).
protected  StyleModel createDefaultStyleModel()
          Creates a new instance of TreeTable.DefaultTreeStyleModel.
protected  TableReorder createReorder()
          Creates and returns a TableReorder that will handle table selection changes.
protected  SpanDrawer createSpanDrawer()
          Returns a new instance of the span drawer that is used to enable cell spanning. The SpanDrawer's associated SpanModel is an instance of TreeTable.DefaultTreeSpanModel.
protected  void doEdit(TableModelEvent e, int newRow, int editMode)
          Discards, commits or continues editing after a model update, according to the edit mode, passed as parameter.
protected  void doProcessMouseEvent(MouseEvent e)
          Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.
protected  void doProcessMouseMotionEvent(MouseEvent e)
          Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.
 boolean editCellAt(int row, int column, EventObject e)
          Programmatically starts editing the cell at row and column, if the cell is editable. To prevent the JTable from editing a particular table, column or cell value, return false from the isCellEditable method in the TableModel interface.
 TableCellRenderer getAggregateCellRenderer(int row, int column)
          Returns a TableCellRenderer component that will be used to render the aggregate row specified by row and column.
 TableCellRenderer getCellRenderer(int row, int column)
          For aggregate rows, this method returns the result from calling getAggregateCellRenderer.
 TableCellRenderer getDefaultAggregateRenderer(Class columnClass)
          Returns the renderer responsible for drawing an aggregate's row column of class specified by columnClass.
 int getEditingRow()
          This method has been overriden in order to take into account the presence of the span model.
protected  int getEditOffset(int row)
          Returns an offset to displace the tree column by, when that cell is being edited.
 JTree getTree()
          Returns the JTree component that is displayed on the first column of the table.
 int getTreeColumn()
          Returns the column that contains the tree.
 TreeTableModelAdapter getTreeTableModelAdapter()
          Convenience method to retrieve the treetable model adapter.
protected  void processKeyEvent(KeyEvent e)
          Overrides processKeyEvent to process events.
 void setDefaultAggregateRenderer(Class columnClass, TableCellRenderer renderer)
          Set a default aggregate renderer to be used for rendering aggregate rows based on their column's class.
 void setModel(TableModel newModel)
          Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.
 void setRowHeight(int rowHeight)
          Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints.
 void setTableReorder(TableReorder newTableReorder)
          Assigns a table reorder that will handle table selection changes.
 void setTreeColumn(int treeColumn)
          Assigns the column that contains the tree.
 void setTreeTableModel(TreeTableModel treeTableModel)
          Assigns a new TreeTableModel.
protected  boolean shouldToggleExpand(int row, int column, EventObject e, boolean editingStarted)
          This method determines the situation under which a treetable's node is expanded/collapsed.
protected  Component superPrepareRenderer(TableCellRenderer renderer, int row, int column)
          Calls the AdvancedJTable.prepareRenderer(javax.swing.table.TableCellRenderer, int, int) method of its superclass.
 void tableChanged(TableModelEvent e)
          Invoked when this table's TableModel generates a TableModelEvent. The TableModelEvent should be constructed in the coordinate system of the model; the appropriate mapping to the view coordinate system is performed by this JTable when it receives the event.

Application code will not use these methods explicitly, they are used internally by JTable.

Note that as of 1.3, this method clears the selection, if any.

 void updateUI()
          Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
 
Methods inherited from class com.citra.table.AdvancedJTable
columnSelectionChanged, columnWillBeAdded, columnWillBeMoved, columnWillBeRemoved, configureEnclosingScrollPane, createDefaultCellResizer, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultEditors, createDefaultNonContiguousSelectionModel, createDefaultRowHeader, createDefaultTableAssistant, createDefaultTableHeader, doEdit, editingStopped, getCellResizer, getColumnClass, getColumnName, getEditMode, getNonContiguousCellSelection, getNonContiguousSelectionModel, getRealEditingRow, getRowHeader, getScrollPane, getShowDummyColumn, getShowRowHeader, getSpanDrawer, getStyleModel, getTableAssistant, getTableReorder, getTableState, getToolTipLocation, getToolTipText, getValueAt, getViewableResizer, handleEvent, initializeLocalVars, isCellEditable, isCellSelected, isDummyColumn, isDummyColumn, isFirstColumnFixed, prepareEditor, prepareRenderer, processMouseEvent, processMouseMotionEvent, removeEditor, scrollRectToVisible, selectAll, setAutoResizeMode, setCellResizer, setColumnModel, setEditMode, setEvenColor, setFirstColumnFixed, setNonContiguousCellSelection, setNonContiguousSelectionModel, setOddColor, setRowHeader, setShowDummyColumn, setShowRowHeader, setSpanDrawer, setStyleModel, setTableAssistant, setTableHeader, setTableState, sizeColumnsToFit, valueChanged
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, convertColumnIndexToModel, convertColumnIndexToView, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editingCanceled, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnCount, getColumnModel, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, setAutoCreateColumnsFromModel, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setUI, setValueAt, sizeColumnsToFit, unconfigureEnclosingScrollPane
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

treeColumn

protected int treeColumn
the column containing the tree


defaultAggregateRenderers

protected transient Hashtable defaultAggregateRenderers
A table of objects that are responsible for drawing the cells of aggregate rows, indexed by class.

Constructor Detail

TreeTable

public TreeTable()
Constructs a TreeTable object with the table's model being returned by the createDefaultDataModel method.


TreeTable

public TreeTable(TreeTableModel model)
Constructs a TreeTable object having model as the TreeTableModelAdapter's treetable model.


TreeTable

public TreeTable(TreeTableModelAdapter adapter)
Constructs a TreeTable object having adapter as the table's model.

Method Detail

changeSelection

public void changeSelection(int rowIndex,
                            int columnIndex,
                            boolean toggle,
                            boolean extend)
Updates the selection models of the table, depending on the state of the two flags: toggle and extend. All changes to the selection that are the result of keyboard or mouse events received by the UI are channeled through this method so that the behavior may be overridden by a subclass.

This implementation uses the following conventions:

Overrides:
changeSelection in class AdvancedJTable
Parameters:
rowIndex - affects the selection at row
columnIndex - affects the selection at column
toggle - see description above
extend - if true, extend the current selection

createDefaultDataModel

protected TableModel createDefaultDataModel()
Creates a new instance of a TreeTableModelAdapter. Returns the default table model object, which is a DefaultTableModel. A subclass can override this method to return a different table model object.

Overrides:
createDefaultDataModel in class JTable
Returns:
the default table model object
See Also:
DefaultTableModel

createDefaultRenderers

protected void createDefaultRenderers()
TreeTable installs a DefaultTreeTableRenderer for each of the basic classes (String, Object, Date, Boolean and Number).

Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.

Overrides:
createDefaultRenderers in class AdvancedJTable
See Also:
DefaultTableCellRenderer

createDefaultStyleModel

protected StyleModel createDefaultStyleModel()
Creates a new instance of TreeTable.DefaultTreeStyleModel. Returns the default style model object which is a DefaultStyleModel.

Overrides:
createDefaultStyleModel in class AdvancedJTable
Returns:
the default style model object

createReorder

protected TableReorder createReorder()
Creates and returns a TableReorder that will handle table selection changes.

Overrides:
createReorder in class AdvancedJTable
Returns:
a new instance of TableReorder

createSpanDrawer

protected SpanDrawer createSpanDrawer()
Returns a new instance of the span drawer that is used to enable cell spanning.

The SpanDrawer's associated SpanModel is an instance of TreeTable.DefaultTreeSpanModel.

Overrides:
createSpanDrawer in class AdvancedJTable
Returns:
a SpanDrawer instance.

doEdit

protected void doEdit(TableModelEvent e,
                      int newRow,
                      int editMode)
Discards, commits or continues editing after a model update, according to the edit mode, passed as parameter. see getEditMode.

Overrides:
doEdit in class AdvancedJTable
Parameters:
e - the model update event triggering the method
newRow - the new row index of the row being edited
editMode - the edit mode

doProcessMouseEvent

protected void doProcessMouseEvent(MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.

Overrides:
doProcessMouseEvent in class AdvancedJTable
Parameters:
e - the 'converted' mouse event

doProcessMouseMotionEvent

protected void doProcessMouseMotionEvent(MouseEvent e)
Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.

Overrides:
doProcessMouseMotionEvent in class AdvancedJTable
Parameters:
e - the 'converted' mouse event

editCellAt

public boolean editCellAt(int row,
                          int column,
                          EventObject e)
Programmatically starts editing the cell at row and column, if the cell is editable. To prevent the JTable from editing a particular table, column or cell value, return false from the isCellEditable method in the TableModel interface.

Overrides:
editCellAt in class AdvancedJTable
Parameters:
row - the row to be edited
column - the column to be edited
e - event to pass into shouldSelectCell; note that as of Java 2 platform v1.2, the call to shouldSelectCell is no longer made
Returns:
false if for any reason the cell cannot be edited

getAggregateCellRenderer

public TableCellRenderer getAggregateCellRenderer(int row,
                                                  int column)
Returns a TableCellRenderer component that will be used to render the aggregate row specified by row and column.

This method returns the appropriate aggregate renderer based on the class of the object found at (row, column). If this value is null, it will return the aggregate renderer for the String class.

Parameters:
row - the index of the row being rendered
column - the index of the column being rendered
Returns:
a TableCellRenderer component

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
For aggregate rows, this method returns the result from calling getAggregateCellRenderer. If the value returned is null or if the row is not aggregate, this method returns the result from it's superclass.

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.

Overrides:
getCellRenderer in class JTable
Parameters:
row - the row of the cell to render, where 0 is the first row
column - the column of the cell to render, where 0 is the first column
Returns:
the assigned renderer; if null returns the default renderer for this type of object
See Also:
DefaultTableCellRenderer, TableColumn.setCellRenderer(javax.swing.table.TableCellRenderer), JTable.setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)

getDefaultAggregateRenderer

public TableCellRenderer getDefaultAggregateRenderer(Class columnClass)
Returns the renderer responsible for drawing an aggregate's row column of class specified by columnClass. The renderer is fetched from a Hashtable of entries (defaultAggregateRenderers) according to the object's class. If there is no entry for this columnClass the method returns the entry for the most specific superclass. TreeTable installs entries for Object, Number, Boolean,String and Date all of which can be modified or replaced.

Parameters:
columnClass - the column's class
Returns:
the aggregate renderer for this columnClass

getEditingRow

public int getEditingRow()
This method has been overriden in order to take into account the presence of the span model. Do not use this method to get the editing row, use getRealEditingRow instead.

Returns the index of the row that contains the cell currently being edited. If nothing is being edited, returns -1.

Overrides:
getEditingRow in class AdvancedJTable
Returns:
the index of the row that contains the cell currently being edited; returns -1 if nothing being edited
See Also:
JTable.editingColumn

getEditOffset

protected int getEditOffset(int row)
Returns an offset to displace the tree column by, when that cell is being edited. This offset usually represents the tree icon on the left of the cell.

Parameters:
row - the row that is being edited
Returns:
the offset of the row

getTree

public JTree getTree()
Returns the JTree component that is displayed on the first column of the table. This tree is a specialized class that is synchronized with the TreeTable instance and should therefore be dealt with carefully. Nevertheless, you can use the tree for various look and feel purposes, such as changing the selection/background colors. You can also specify the icons of the tree by taking its cell renderer, which is an instance of DefaultTreeCellRenderer:

DefaultTreeCellRenderer tcr = (DefaultTreeCellRenderer) treeTable.getTree().getCellRenderer();
ImageIcon leafIcon = new ImageIcon("c:\\icons\\leafIcon.gif");
ImageIcon closedIcon = new ImageIcon("c:\\icons\\closedIcon.gif");
tcr.setLeafIcon(leafIcon);
tcr.setClosedIcon(closedIcon);

Returns:
the tree associated with this TreeTable.

getTreeColumn

public int getTreeColumn()
Returns the column that contains the tree.

Returns:
the column containing the tree

getTreeTableModelAdapter

public TreeTableModelAdapter getTreeTableModelAdapter()
Convenience method to retrieve the treetable model adapter.

Returns:
the treetable model adapter.

processKeyEvent

protected void processKeyEvent(KeyEvent e)
Overrides processKeyEvent to process events.

Overrides:
processKeyEvent in class JComponent
Parameters:
e - the key event
See Also:
KeyEvent, KeyListener, Component.addKeyListener(java.awt.event.KeyListener), Component.enableEvents(long), Component.isShowing()

setDefaultAggregateRenderer

public void setDefaultAggregateRenderer(Class columnClass,
                                        TableCellRenderer renderer)
Set a default aggregate renderer to be used for rendering aggregate rows based on their column's class. If renderer is null, the default aggregate renderer for this column class is removed.

Parameters:
columnClass - set the default aggregate renderer for this columnClass
renderer - default aggregate renderer to be used for this columnClass

setModel

public void setModel(TableModel newModel)
Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.

Overrides:
setModel in class AdvancedJTable
Parameters:
newModel - the new data source for this table
See Also:
JTable.getModel()

setRowHeight

public void setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints. The height of the cells will be equal to the row height minus the row margin.

Overrides:
setRowHeight in class JTable
Parameters:
rowHeight - new row height
See Also:
JTable.getRowHeight()

setTableReorder

public void setTableReorder(TableReorder newTableReorder)
Assigns a table reorder that will handle table selection changes.

Overrides:
setTableReorder in class AdvancedJTable
Parameters:
newTableReorder - the TableReorder object to assign.

setTreeColumn

public void setTreeColumn(int treeColumn)
Assigns the column that contains the tree. The default is the first column (0).

Parameters:
treeColumn - the column containing the tree

setTreeTableModel

public void setTreeTableModel(TreeTableModel treeTableModel)
Assigns a new TreeTableModel.

Parameters:
treeTableModel - the new tree tablemodel to assign.

shouldToggleExpand

protected boolean shouldToggleExpand(int row,
                                     int column,
                                     EventObject e,
                                     boolean editingStarted)
This method determines the situation under which a treetable's node is expanded/collapsed. By default, a node is expanded/collapsed if we are not editing and the event is a mouse event with a click count of two. You may override this method to define a custom behaviour.

Parameters:
row - the row we wish to expand/collapse
column - the column we wish to expand/collapse
e - the event that is used to expand/collapse the node, usually a MouseEvent
editingStarted - boolean indicating whether we are editing
Returns:
true if the node should be expanded/collapsed, false otherwise

superPrepareRenderer

protected Component superPrepareRenderer(TableCellRenderer renderer,
                                         int row,
                                         int column)
Calls the AdvancedJTable.prepareRenderer(javax.swing.table.TableCellRenderer, int, int) method of its superclass. Usefull for customizing the default behaviour of the first-tree column.


tableChanged

public void tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates a TableModelEvent. The TableModelEvent should be constructed in the coordinate system of the model; the appropriate mapping to the view coordinate system is performed by this JTable when it receives the event.

Application code will not use these methods explicitly, they are used internally by JTable.

Note that as of 1.3, this method clears the selection, if any.

Specified by:
tableChanged in interface TableModelListener
Overrides:
tableChanged in class AdvancedJTable

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.

Overrides:
updateUI in class AdvancedJTable
See Also:
JComponent.updateUI()

Copyright © 2011 Citra Technologies. All Rights Reserved.