JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class JCSortableTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTable
                          |
                          +--com.klg.jclass.util.swing.JCSortableTable
All Implemented Interfaces:
Accessible, CellEditorListener, EventListener, ImageObserver, ListSelectionListener, MenuContainer, Scrollable, Serializable, TableColumnModelListener, TableModelListener
Direct Known Subclasses:
JCTreeExplorer.TreeIconRenderTable, JCTreeTable

public class JCSortableTable
extends JTable

JCSortableTable class.

See Also:
Serialized Form

Nested Class Summary
static interface JCSortableTable.SortableColumnHeader
          Interface required by the column header component (if not a JLabel or JButton) to allow setting of the sort icon.
protected  class JCSortableTable.SortableHeaderRenderer
          Renderer/editor that has two components: the label and the sort order icon, which is stored in a button.
protected  class JCSortableTable.SortableTableColumn
          Overridden version of TableColumn that returns SortableColumnRenderer instead of the normal default.
 class JCSortableTable.SortIcon
          Internal sorting icon class.
protected  class JCSortableTable.TableHeaderMouseListener
          MouseAdapter for the table header.
 
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
protected  Icon downIcon
           
protected  com.klg.jclass.util.swing.JCRowSortTableModel sortModel
           
protected  MouseListener tableHeaderMouseListener
           
protected  Icon upIcon
           
 
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
JCSortableTable()
          JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting.
JCSortableTable(int numRows, int numColumns)
          JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting.
JCSortableTable(Object[][] rowData, Object[] columnNames)
          JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting.
JCSortableTable(TableModel dm)
          JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting.
JCSortableTable(TableModel dm, TableColumnModel cm)
          JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting.
JCSortableTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
          JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting.
JCSortableTable(Vector rowData, Vector columnNames)
          JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting.
 
Method Summary
protected  void addTableHeaderMouseListener()
          Adds a MouseListener to the table header.
protected  boolean checkColumnModel(TableColumnModel cm)
          Makes sure passed in column model will work with JCSortableTable.
protected  void clearSortIcons()
          Removes sorting icons from the column headers.
protected  void configureEnclosingScrollPane()
          Overwrites the default implementation to remove a MouseListener from the table header.
 void createDefaultColumnsFromModel()
          Overridden from superclass to allow autocreation of our own column model.
 TableColumn createSortableTableColumn(int column)
          This method creates a TableColumn for use in JCSorttableTable.
protected  MouseAdapter createTableHeaderMouseListener()
          Creates a new table header mouse listener.
 String getAbout()
          Returns vendor information.
 boolean getAutoSort()
          Returns whether the data is automatically sorted when it changes according the current comparator.
 TableCellEditor getCellEditor(int row, int column)
          Gets the cell editor for a given cell.
 TableCellRenderer getCellRenderer(int row, int column)
          Gets the cell renderer for a given cell.
 Icon getDownIcon()
          Gets the icon used for reverse sorting.
 int[] getKeyColumns(int column)
          Returns the key columns used to sort the table model when clicking on the specified column.
 Dimension getPreferredSize()
          Override this method to allow a different default preferred size for design time.
 int getSortedRow(int row)
          Returns the unsorted row index of specified sorted row.
protected  MouseListener getTableHeaderMouseListener()
          Gets the current table header mouse listener.
 int getUnsortedRow(int sortedRow)
          Returns the unsorted row index of specified sorted row.
 Icon getUpIcon()
          Gets the icon used for forward sorting.
protected  void reLayoutColumnRenderers()
          Iterate through the columns to get the renderer so that we can reset the horizontal alignment on JCCellRenderers.
protected  void removeTableHeaderMouseListener()
          Removes a MouseListener from the table header.
 void setAbout(String s)
          Provided for Beans property editors - has no effect.
 void setAutoSort(boolean autoSort)
          Sets whether the data should be automatically sorted when it changes.
 void setColumnModel(TableColumnModel columnModel)
          This JTable method is overridden to check and see if the passed in column model is compatible with JCSortableTable.
protected static void setComponentOrientation(Component c, ComponentOrientation o, boolean force)
          Set component orientation on component c to the passed in orientation if its different.
 void setComponentOrientation(ComponentOrientation o)
          Override so that the layout on the header renderers can be redone.
 void setDownIcon(Icon downIcon)
          Sets the icon used for reverse sorting.
 void setKeyColumns(int column, int[] keyColumns)
          Sets the key columns used to sort the table model when clicking on specified column.
 void setModel(TableModel newModel)
          Sets the data model for this table to newModel and registers for listner notifications from the new data model.
protected  void setSortIcon(Component renderer, Icon sortIcon)
          Looks at the renderer (and possibly its children) and sets the sort icon on any JLabels or JButtons that are found.
protected  void setSortIcon(int column)
          Sets or removes the sorting icon.
protected  void setSortIcon(int column, int order)
          Sets or removes the sorting icon.
 void setTableHeader(JTableHeader newHeader)
          Overwrites the default implementation to add a MouseListener to the new table header.
protected  void setTableHeaderMouseListener(MouseListener l)
          Sets the table header mouse listener.
 void setUpIcon(Icon upIcon)
          Sets the icon used for forward sorting.
 void sort(int column)
          Sorts rows using the quicksort algorithm.
 void tableChanged(TableModelEvent e)
          Overrides super class method to check for a change in sorting.
 void unsort()
          Restores the unsorted order.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, 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, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, unconfigureEnclosingScrollPane, updateUI, valueChanged
 
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, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, 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, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, 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

upIcon

protected Icon upIcon

downIcon

protected Icon downIcon

sortModel

protected com.klg.jclass.util.swing.JCRowSortTableModel sortModel

tableHeaderMouseListener

protected MouseListener tableHeaderMouseListener
Constructor Detail

JCSortableTable

public JCSortableTable()
JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting. Clicking on a column header invokes the sorting behavior tied to that column, clicking again reverses the sort.


JCSortableTable

public JCSortableTable(TableModel dm)
JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting. Clicking on a column header invokes the sorting behavior tied to that column, clicking again reverses the sort.

Parameters:
dm - the data model for the table

JCSortableTable

public JCSortableTable(TableModel dm,
                       TableColumnModel cm)
JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting. Clicking on a column header invokes the sorting behavior tied to that column, clicking again reverses the sort.

Parameters:
dm - the data model for the table
cm - the column model for the table

JCSortableTable

public JCSortableTable(TableModel dm,
                       TableColumnModel cm,
                       ListSelectionModel sm)
JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting. Clicking on a column header invokes the sorting behavior tied to that column, clicking again reverses the sort.

Parameters:
dm - the data model for the table
cm - the column model for the table
sm - the row selection model for the table

JCSortableTable

public JCSortableTable(int numRows,
                       int numColumns)
JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting. Clicking on a column header invokes the sorting behavior tied to that column, clicking again reverses the sort.

Parameters:
numRows - the number of rows the table holds
numColumns - the number of columns the table holds
See Also:
DefaultTableModel

JCSortableTable

public JCSortableTable(Vector rowData,
                       Vector columnNames)
JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting. Clicking on a column header invokes the sorting behavior tied to that column, clicking again reverses the sort.

Parameters:
rowData - the data for the new table
columnNames - the names of each column
Since:
JClass 4.0K for Java 2.

JCSortableTable

public JCSortableTable(Object[][] rowData,
                       Object[] columnNames)
JCSortableTable is a subclass of JTable that internally wraps any TableModel it is given with a JCRowSortTableModel and provides a Comparator that has a configureable list of the column indexes that it uses for sorting. Clicking on a column header invokes the sorting behavior tied to that column, clicking again reverses the sort.

Parameters:
rowData - the data for the new table
columnNames - the names of each column
Method Detail

getPreferredSize

public Dimension getPreferredSize()
Override this method to allow a different default preferred size for design time.

Overrides:
getPreferredSize in class JComponent
Returns:
the preferred size of the table

setAbout

public void setAbout(String s)
Provided for Beans property editors - has no effect.

Parameters:
s - the about String

getAbout

public String getAbout()
Returns vendor information.

Returns:
the current about String which is the version String

setModel

public void setModel(TableModel newModel)
Sets the data model for this table to newModel and registers for listner notifications from the new data model. It wraps the TableModel with a JCRowSortTableModel and adds a mouse listener to the new table header.

Overrides:
setModel in class JTable
Parameters:
newModel - the new data model for the table

getSortedRow

public int getSortedRow(int row)
Returns the unsorted row index of specified sorted row.

Parameters:
row - the unsorted row index
Returns:
the sorted row index

getUnsortedRow

public int getUnsortedRow(int sortedRow)
Returns the unsorted row index of specified sorted row.

Parameters:
sortedRow - the sorted row index
Returns:
the unsorted row index

getAutoSort

public boolean getAutoSort()
Returns whether the data is automatically sorted when it changes according the current comparator.

Returns:
the current value of autoSort

setAutoSort

public void setAutoSort(boolean autoSort)
Sets whether the data should be automatically sorted when it changes.

Parameters:
autoSort - the new value of autoSort

setKeyColumns

public void setKeyColumns(int column,
                          int[] keyColumns)
Sets the key columns used to sort the table model when clicking on specified column.

Parameters:
column - index of columns in TableModel
keyColumns - columns to use as keys to sort when sorting on the specified column

getKeyColumns

public int[] getKeyColumns(int column)
Returns the key columns used to sort the table model when clicking on the specified column. If the user has not set the key columns, the method returns an array of length 1 with the specified column as the only member.

Parameters:
column - the column for which the key columns are required
Returns:
the columns to use as keys to sort when sorting on the specified column

getUpIcon

public Icon getUpIcon()
Gets the icon used for forward sorting.

Returns:
the current icon used for forward sorting

setUpIcon

public void setUpIcon(Icon upIcon)
Sets the icon used for forward sorting.

Parameters:
upIcon - the new icon used for forward sorting

getDownIcon

public Icon getDownIcon()
Gets the icon used for reverse sorting.

Returns:
the current icon used for reverse sorting

setDownIcon

public void setDownIcon(Icon downIcon)
Sets the icon used for reverse sorting.

Parameters:
downIcon - the new icon used for reverse sorting

setTableHeader

public void setTableHeader(JTableHeader newHeader)
Overwrites the default implementation to add a MouseListener to the new table header.

Overrides:
setTableHeader in class JTable
Parameters:
newHeader - the new table header

getCellEditor

public TableCellEditor getCellEditor(int row,
                                     int column)
Gets the cell editor for a given cell.

Overrides:
getCellEditor in class JTable
Parameters:
row - the row index of the specified cell
column - the column index of the specified cell
Returns:
the current cell editor for the cell

getCellRenderer

public TableCellRenderer getCellRenderer(int row,
                                         int column)
Gets the cell renderer for a given cell.

Overrides:
getCellRenderer in class JTable
Parameters:
row - the row index of the specified cell
column - the column index of the specified cell
Returns:
the current cell renderer for the cell

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
Overwrites the default implementation to remove a MouseListener from the table header.

Overrides:
configureEnclosingScrollPane in class JTable

addTableHeaderMouseListener

protected void addTableHeaderMouseListener()
Adds a MouseListener to the table header.


removeTableHeaderMouseListener

protected void removeTableHeaderMouseListener()
Removes a MouseListener from the table header.


getTableHeaderMouseListener

protected MouseListener getTableHeaderMouseListener()
Gets the current table header mouse listener.

Returns:
the current table header mouse listener

setTableHeaderMouseListener

protected void setTableHeaderMouseListener(MouseListener l)
Sets the table header mouse listener.

Parameters:
l - the new table header mouse listener

createTableHeaderMouseListener

protected MouseAdapter createTableHeaderMouseListener()
Creates a new table header mouse listener.

Returns:
the new table header mouse listener

sort

public void sort(int column)
Sorts rows using the quicksort algorithm.

Parameters:
column - the column to sort on

unsort

public void unsort()
Restores the unsorted order.


tableChanged

public void tableChanged(TableModelEvent e)
Overrides super class method to check for a change in sorting.

Specified by:
tableChanged in interface TableModelListener
Overrides:
tableChanged in class JTable
Parameters:
e - the event that caused the table to change

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Overridden from superclass to allow autocreation of our own column model.

Overrides:
createDefaultColumnsFromModel in class JTable
See Also:
JTable.createDefaultColumnsFromModel()

checkColumnModel

protected boolean checkColumnModel(TableColumnModel cm)
Makes sure passed in column model will work with JCSortableTable.

Parameters:
cm - the column model
Returns:
a boolean indicating whether the column model is compatible with JCSortableTable

setColumnModel

public void setColumnModel(TableColumnModel columnModel)
This JTable method is overridden to check and see if the passed in column model is compatible with JCSortableTable.

Overrides:
setColumnModel in class JTable
Parameters:
columnModel - the new column model

createSortableTableColumn

public TableColumn createSortableTableColumn(int column)
This method creates a TableColumn for use in JCSorttableTable. Override it in subclasses to easily change which type of Column is created by default.

Parameters:
column - the column for which the TableColumn is to be created
Returns:
the newly created TableColumn

clearSortIcons

protected void clearSortIcons()
Removes sorting icons from the column headers.


setSortIcon

protected void setSortIcon(int column)
Sets or removes the sorting icon.

Parameters:
column - the column on which the sort icon is to be set

setSortIcon

protected void setSortIcon(Component renderer,
                           Icon sortIcon)
Looks at the renderer (and possibly its children) and sets the sort icon on any JLabels or JButtons that are found.

Parameters:
renderer - the renderer on which the sortIcon is to be set
sortIcon - the new sortIcon to be used for the renderer

setSortIcon

protected void setSortIcon(int column,
                           int order)
Sets or removes the sorting icon.

Parameters:
column - the column on which the sort icon is to be set
order - Determines whether the up or down icon is to be used. Possible values are JCRowSortModel.FORWARD and JCRowSortModel.REVERSE. Any other values causes no icon to be used.

setComponentOrientation

protected static void setComponentOrientation(Component c,
                                              ComponentOrientation o,
                                              boolean force)
Set component orientation on component c to the passed in orientation if its different. Also, only change the orientation if it has not been explicitly set before.

Parameters:
c - The component whose orientation may be set.
o - The new orientation
force - If true, force an orientation change, even if it has been explicitly set before.

setComponentOrientation

public void setComponentOrientation(ComponentOrientation o)
Override so that the layout on the header renderers can be redone.

Note: Due to problems with column ordering in JTable, JCSortableTable and JCTreeTable will not behave properly for a right to left orientation for JDKs prior to 1.4.0.

Overrides:
setComponentOrientation in class Component
Parameters:
o - The new component orientation.

reLayoutColumnRenderers

protected void reLayoutColumnRenderers()
Iterate through the columns to get the renderer so that we can reset the horizontal alignment on JCCellRenderers.


Copyright © 2004 Quest Software Inc..
All rights reserved.