Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

oracle.javatools.ui.table
Class GenericTable

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 oracle.javatools.ui.table.GenericTable
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.RowSorterListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable, DisplayableTable
Direct Known Subclasses:
NiceTable

public class GenericTable
extends javax.swing.JTable
implements DisplayableTable

GenericTable is a subclass of JTable with a number of nice and enhanced features and a cleaner UI.

Features provided by this GenericTable:

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.AccessibleJTable, javax.swing.JTable.DropLocation, javax.swing.JTable.PrintMode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
GenericTable()
          Constructs a default GenericTable that is initialized with a default data model, a default column model, and a default selection model.
GenericTable(java.lang.Object[][] rowData, java.lang.Object[] columnNames)
          Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model.
GenericTable(javax.swing.table.TableModel model)
          Constructs a GenericTable that is initialized with dm as the data model, a default column model, and a default selection model.
GenericTable(java.util.Vector rowData, java.util.Vector columnNames)
          Constructs a GenericTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
 
Method Summary
 void autoSizeColumnsToFit()
          Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents.
 void autoSizeColumnsToFit(java.lang.Object[] prototypeValues)
          Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents.
 void autoSizeViewportToFit(java.awt.Dimension min, java.awt.Dimension max)
          Automatically sizes the viewport to fix the current data in the table, given a minimum and maximum size.
protected  void configureEnclosingScrollPane()
          Override to configure the scrollpane for this table.
 java.lang.String convertValueToText(java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
          Called by the renderers to convert the specified value to text.
protected  void createDefaultRenderers()
          Override to creates default GenericTableCellRenderer for objects, numbers, doubles, dates, booleans, and icons.
 RowHeader createDefaultRowHeader()
          Creates a default RowHeader for this table.
 javax.swing.JPopupMenu createSelectorMenu()
          Create the selector menu which is used to select and deselect columns.
 javax.swing.Action[] getColumnSelectorActions()
          Returns the additional column selector actions if it has been set before.
protected static java.awt.Color getDarker(java.awt.Color c)
          Get a very slightly darker shade of the specified color.
 javax.swing.table.TableCellRenderer getDefaultRenderer(java.lang.Class<?> columnClass)
          Override to fix JDK bug if columnClass is null.
 int[] getHiddenColumns()
          Get columns that are hidden.
protected  java.lang.String getJTableToolTipText(java.awt.event.MouseEvent e)
          Method for subclasses to call which want to avoid NiceTable functionality in getToolTipText(MouseEvent)
 java.lang.String getNoEntryInstructionText()
          Returns the instruction text of the table when there is no entry in the table.
 GenericTablePersistentSettings getPersistentSettings()
          Get a javabean storing persistent settings of this NiceTable which you can serialize in order to restore the visible appearance of the table next time it is used.
 java.awt.Dimension getPreferredSize()
          Override to return a height of 2 rows for the table when there are no elements in the table.
 int getPreferredVisibleRowCount()
          Returns the value of the visibleRowCount property.
 RowHeader getRowHeader()
          Returns the row header of this generic table.
 javax.swing.Action getSelectColumnsAction()
          Returns the additional select columns action if it has been set before.
 int getSelectedRowInModel()
          Get the selected row as a model row, regardless of whether this table is currently sorted.
 int[] getSelectedRowsInModel()
          Get the selected rows as model rows, regardless of whether this table is currently sorted.
 int getSortColumn()
          Get the (model) sort column
 java.awt.Color getSortColumnBackgroundColor()
          Get the background color of the sorted column.
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
          Override to provide a tooltip for cells that are obscured because they are too small to display their renderer properly.
 boolean getUseTransferHandler()
          Get whether the default TransferHandler from the look and feel is associated with this component when the UI is initialized.
protected  void installGenericTableRenderer()
           
 boolean isColumnHeaderSelectionEnabled()
          Returns whether column header selection is supported for the table.
 boolean isColumnSelectorAvailable()
          Get whether the dropdown button is displayed at the end of the column header for hiding and showing columns is available on this instance of table.
 boolean isResizeColumnOnDoubleClick()
          Get whether the user can resize columns in this table by double clicking the resize divider between two columns.
 boolean isRolloverHighlightingEnabled()
          Returns whether rollover highlighting is enabled/disabled on the table.
 boolean isSelectAllEnabled()
          Returns whether selectAll feature is enabled for the table.
 boolean isShowToolTips()
          Get whether tooltips are being shown for truncated cells.
 boolean isSortAscending()
          Is the sorted column being sorted in ascending order?
 boolean isSorted()
          Is the table sorted?
protected  void paintComponent(java.awt.Graphics g)
          Override the paint component to paint the background of the sorted column in a slightly different color from other columns.
 java.awt.Component prepareEditor(javax.swing.table.TableCellEditor editor, int row, int column)
          Override to set the initial value to null in case of text editors as per the UI guidelines.
protected  boolean processKeyBinding(javax.swing.KeyStroke ks, java.awt.event.KeyEvent e, int condition, boolean pressed)
           
 void reSort()
          Convenience method that reapplies the current sort.
 void scrollToSelection()
          Scrolls the table's viewport to the currently selected row and column.
 void selectAll()
          Stop cell editing when the user select all cells.
 void setBackground(java.awt.Color c)
          Overridden to make sure the highlighted column is repainted properly.
 void setColumnHeaderSelectionEnabled(boolean select)
          Add column header selection support for the table.
 void setColumnSelectorActions(javax.swing.Action... actions)
          This method adds the specified actions to the end of ColumnSelector dropdow menu.
 void setColumnSelectorAvailable(boolean isAvailable)
          Set whether this table will display a dropdown button at the end of the column header to hide/show columns.
protected  void setColumnVisible(javax.swing.table.TableColumn column, int modelColumn, boolean isVisible)
          Makes the column visible it it can be hidden.
 void setDefaultRenderer(java.lang.Class<?> columnClass, javax.swing.table.TableCellRenderer renderer)
           
 void setHiddenColumns(int... hiddenColumns)
          Set columns that are hidden.
 void setHiddenColumnsVisible(int[] columns)
          Set columns that were previously hidden visible again.
 void setModel(javax.swing.table.TableModel dataModel)
           
 void setNoEntryInstructionText(java.lang.String text)
          Sets the instruction text on the firt row of the table when there is no entry in the table.
 void setPersistentSettings(GenericTablePersistentSettings settings)
          Set the persistent view settings of this NiceTable.
 void setPreferredVisibleRowCount(int visibleRowCount)
          Sets the visibleRowCount property.
 void setResizeColumnOnDoubleClick(boolean isOn)
          Set whether the user can resize columns in this table by double clicking the resize divider between two columns.
 void setRolloverHighlightingEnabled(boolean highlight)
          Set rollover highlighting enabled/disabled on the table.
 void setRowHeader(RowHeader rowHeader)
          Sets the row header for this table.
 void setSelectAllEnabled(boolean enable)
          Enables whether the user can click on upper left corner to select all cells in the table by clicking on it.
 void setSelectColumnsAction(javax.swing.Action selectColumn)
          This method adds the specified SelectColumns action to the end of ColumnSelector dropdow menu.
 void setSelectedRowInModel(int selectedRowInModel)
          Select the specified model row, regardless of its position in the (sorted or unsorted) view.
 void setSelectedRowsInModel(int[] selectedRowsInModel)
          Select the specified model rows, regardless of their position in the (sorted or unsorted) view.
 void setShowToolTips(boolean showToolTips)
          Controls whether this GenericTable will show tooltips for cells that are truncated due to reduced column width.
 void setSortColumn(int modelColumn, boolean isSortAscending)
          Set the column to sort the view by.
 void setSortColumnBackgroundColor(java.awt.Color c)
          Set the background color used to highlight the sorted column.
 void setSorted(boolean isSorted)
          Set whether this GenericTable is sorted.
 void setUI(javax.swing.plaf.TableUI ui)
          Override to use the transferhandler that uses convertValueToText to copying the text.
 void setUseTransferHandler(boolean useTransferHandler)
          Set whether the default TransferHandler from the look and feel is associated with this component when the UI is initialized.
 void setVisibleRows(int rows)
          Sets the number of visible rows on the table.
 void sizeTableToContents()
          Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents.
 void sizeTableToContents(java.lang.Object[] prototypeValues)
          Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents.
protected  void unconfigureEnclosingScrollPane()
          Override to unconfigure the scrollpane for this table.
 void updateUI()
          Overridden to make sure look and feel changes cause the highlighted column to be repainted in the right color.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareRenderer, print, print, print, print, print, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, valueChanged
 
Methods inherited from class javax.swing.JComponent
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, hide, 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, 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
 

Constructor Detail

GenericTable

public GenericTable()
Constructs a default GenericTable that is initialized with a default data model, a default column model, and a default selection model.


GenericTable

public GenericTable(javax.swing.table.TableModel model)
Constructs a GenericTable that is initialized with dm as the data model, a default column model, and a default selection model.


GenericTable

public GenericTable(java.util.Vector rowData,
                    java.util.Vector columnNames)
Constructs a GenericTable that is initialized with dm as the data model, cm as the column model, and a default selection model.


GenericTable

public GenericTable(java.lang.Object[][] rowData,
                    java.lang.Object[] columnNames)
Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model.

Method Detail

getSortColumn

public int getSortColumn()
Get the (model) sort column

Returns:
the column in the model that the table view is being sorted by

isSortAscending

public boolean isSortAscending()
Is the sorted column being sorted in ascending order?


setColumnSelectorAvailable

public void setColumnSelectorAvailable(boolean isAvailable)
Set whether this table will display a dropdown button at the end of the column header to hide/show columns. To get this feature, table should be put inside a JScrollPane.

Parameters:
isAvailable - if true, a dropdown button will be provided at the end of the column header of this table with checkbox menu items for each column. The user can use these to hide and show columns.

isColumnSelectorAvailable

public boolean isColumnSelectorAvailable()
Get whether the dropdown button is displayed at the end of the column header for hiding and showing columns is available on this instance of table.

Returns:
whether the column selector drop down button is available.

setSelectColumnsAction

public void setSelectColumnsAction(javax.swing.Action selectColumn)
This method adds the specified SelectColumns action to the end of ColumnSelector dropdow menu. The name from the action is used as the menu item label. Before setting this action, clients should turn on the column selector using setColumnSelectorAvailable.


getSelectColumnsAction

public javax.swing.Action getSelectColumnsAction()
Returns the additional select columns action if it has been set before.


setColumnSelectorActions

public void setColumnSelectorActions(javax.swing.Action... actions)
This method adds the specified actions to the end of ColumnSelector dropdow menu. The name from the action is used as the menu item label. Before setting these actions, clients should turn on the column selector using setColumnSelectorAvailable.


getColumnSelectorActions

public javax.swing.Action[] getColumnSelectorActions()
Returns the additional column selector actions if it has been set before.


createSelectorMenu

public javax.swing.JPopupMenu createSelectorMenu()
Create the selector menu which is used to select and deselect columns.

Returns:
a JPopupMenu with items for each column.

setHiddenColumns

public void setHiddenColumns(int... hiddenColumns)
Set columns that are hidden. You should only call this after setting the model.

Parameters:
hiddenColumns - columns which are currently hidden

getHiddenColumns

public int[] getHiddenColumns()
Get columns that are hidden. You should only call this after setting the model.

Returns:
an array of model column indices

setHiddenColumnsVisible

public void setHiddenColumnsVisible(int[] columns)
Set columns that were previously hidden visible again. You should only call this after setting the model.

Parameters:
columns - An array of hidden columns to be made visible

setNoEntryInstructionText

public void setNoEntryInstructionText(java.lang.String text)
Sets the instruction text on the firt row of the table when there is no entry in the table. The instruction text must be in the form: "No object Name".


getNoEntryInstructionText

public java.lang.String getNoEntryInstructionText()
Returns the instruction text of the table when there is no entry in the table. This instruction text will be displayed on the first row of the table.


setShowToolTips

public void setShowToolTips(boolean showToolTips)
Controls whether this GenericTable will show tooltips for cells that are truncated due to reduced column width. By default this is true.

Parameters:
showToolTips - if true, a tooltip will be displayed for any cell which is truncated because the column is not wide enough to display its full value.

isShowToolTips

public boolean isShowToolTips()
Get whether tooltips are being shown for truncated cells.

Returns:
true if tooltips are being shown for truncated cells.

setResizeColumnOnDoubleClick

public void setResizeColumnOnDoubleClick(boolean isOn)
Set whether the user can resize columns in this table by double clicking the resize divider between two columns. This behavior is ON by default. This property works best if the column auto-resizing behavior is turned off in the table. You can turn it off using:
   table.setAutoResizeMode( GenericTable.AUTO_RESIZE_OFF );
 

Parameters:
isOn - if true, the user can resize columns

isResizeColumnOnDoubleClick

public boolean isResizeColumnOnDoubleClick()
Get whether the user can resize columns in this table by double clicking the resize divider between two columns. This behavior is ON by default.


sizeTableToContents

public void sizeTableToContents()
Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents.

This method works best when the column auto-resizing behavior is turned off. You can turn it off using:

   table.setAutoResizeMode( GenericTable.AUTO_RESIZE_OFF );
 

See Also:
JTable.setAutoResizeMode(int)

sizeTableToContents

public void sizeTableToContents(java.lang.Object[] prototypeValues)
Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents. The prototypeValues, if specified is used as the base or minimum width for the columns.

This method works best when the column auto-resizing behavior is turned off. You can turn it off using:

   table.setAutoResizeMode( GenericTable.AUTO_RESIZE_OFF );
 

See Also:
JTable.setAutoResizeMode(int)

autoSizeViewportToFit

public final void autoSizeViewportToFit(java.awt.Dimension min,
                                        java.awt.Dimension max)
Automatically sizes the viewport to fix the current data in the table, given a minimum and maximum size.

Parameters:
min - the minimum size. Optional. If null, no minimum is used.
max - the maximum size. Optional. If null, no maximum is used.
Since:
11.1.1

autoSizeColumnsToFit

public void autoSizeColumnsToFit()
Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents. The width of each column is restricted to GenericTableAutoSizeModel.getColumnAutoSizeMaximum, if the table model is an instance of GenericTableAutoSizeModel.

This method works best when the column auto-resizing behavior is turned off. You can turn it off using:

   table.setAutoResizeMode( GenericTable.AUTO_RESIZE_OFF );
 

See Also:
JTable.setAutoResizeMode(int)

autoSizeColumnsToFit

public void autoSizeColumnsToFit(java.lang.Object[] prototypeValues)
Utility method that will set the preferred width of all columns in this table so that they are just large enough to fully display their current contents. The prototypeValues, if specified is used as the base or minimum width for the columns. However, the width of each colun is restricted to GenericTableAutoSizeModel.getColumnAutoSizeMaximum, if the table model is an instance of GenericTableAutoSizeModel.

This method works best when the column auto-resizing behavior is turned off. You can turn it off using:

   table.setAutoResizeMode( GenericTable.AUTO_RESIZE_OFF );
 

Parameters:
prototypeValues - array of data values for each column, which will be used in the calculation of minimum width for each column in the table.
See Also:
JTable.setAutoResizeMode(int)

setVisibleRows

public void setVisibleRows(int rows)
Sets the number of visible rows on the table. This basically sets the preferred size of the table's scroll pane. If the table is current visible this also revalidates the scrollpane.


setPreferredVisibleRowCount

public void setPreferredVisibleRowCount(int visibleRowCount)
Sets the visibleRowCount property. This sets the preferred number of rows to display without requiring scrolling. Setting this property affects the return value of the JTable.getPreferredScrollableViewportSize() method, which is used to calculate the preferred size of an enclosing viewport. See that method's documentation for more details.

The default value of this property is -1, indicating null PreferredScrollableViewportSize.

Calling this method with a negative value will set the PreferredScrollableViewportSize to null.

Parameters:
visibleRowCount - an integer specifying the preferred number of rows to display without requiring scrolling
See Also:
getPreferredVisibleRowCount(), JTable.getPreferredScrollableViewportSize(), JViewport

getPreferredVisibleRowCount

public int getPreferredVisibleRowCount()
Returns the value of the visibleRowCount property. See the documentation for setPreferredVisibleRowCount(int) for details on how to interpret this value.

Returns:
the value of the visibleRowCount property.
See Also:
setPreferredVisibleRowCount(int)

setRowHeader

public void setRowHeader(RowHeader rowHeader)
Sets the row header for this table. Table takes care of automatically setting this as the row header view of the scroll pane to which it is added.


getRowHeader

public RowHeader getRowHeader()
Returns the row header of this generic table.


createDefaultRowHeader

public RowHeader createDefaultRowHeader()
Creates a default RowHeader for this table.


setColumnHeaderSelectionEnabled

public void setColumnHeaderSelectionEnabled(boolean select)
Add column header selection support for the table. Enabling this property will select the table column when clicked on corresponding table header.


isColumnHeaderSelectionEnabled

public boolean isColumnHeaderSelectionEnabled()
Returns whether column header selection is supported for the table.


setSelectAllEnabled

public void setSelectAllEnabled(boolean enable)
Enables whether the user can click on upper left corner to select all cells in the table by clicking on it. This will work only if the table is added to the view component of a scroll pane and has a RowHeader.


isSelectAllEnabled

public boolean isSelectAllEnabled()
Returns whether selectAll feature is enabled for the table.


setRolloverHighlightingEnabled

public void setRolloverHighlightingEnabled(boolean highlight)
Set rollover highlighting enabled/disabled on the table. This method should be called after setting any all the renders on the table. This will not work if the renders are changed after this call. By default, rolloverhighlighting is enabled for the table.


isRolloverHighlightingEnabled

public boolean isRolloverHighlightingEnabled()
Returns whether rollover highlighting is enabled/disabled on the table.


setDefaultRenderer

public void setDefaultRenderer(java.lang.Class<?> columnClass,
                               javax.swing.table.TableCellRenderer renderer)
Overrides:
setDefaultRenderer in class javax.swing.JTable

setUseTransferHandler

public void setUseTransferHandler(boolean useTransferHandler)
Set whether the default TransferHandler from the look and feel is associated with this component when the UI is initialized.

The default for this property is false.

Parameters:
useTransferHandler - true if the transfer handler from the L&F will be used.

getUseTransferHandler

public boolean getUseTransferHandler()
Get whether the default TransferHandler from the look and feel is associated with this component when the UI is initialized.

The default for this property is false.

Returns:
true if the transfer handler from the L&F will be used.

setSortColumnBackgroundColor

public void setSortColumnBackgroundColor(java.awt.Color c)
Set the background color used to highlight the sorted column.

Parameters:
c - the color to paint the background of the sorted column

setBackground

public void setBackground(java.awt.Color c)
Overridden to make sure the highlighted column is repainted properly.

Overrides:
setBackground in class javax.swing.JComponent
Parameters:
c -

updateUI

public void updateUI()
Overridden to make sure look and feel changes cause the highlighted column to be repainted in the right color.

Overrides:
updateUI in class javax.swing.JTable

prepareEditor

public java.awt.Component prepareEditor(javax.swing.table.TableCellEditor editor,
                                        int row,
                                        int column)
Override to set the initial value to null in case of text editors as per the UI guidelines.

Overrides:
prepareEditor in class javax.swing.JTable

getSortColumnBackgroundColor

public java.awt.Color getSortColumnBackgroundColor()
Get the background color of the sorted column. By default, this is a slightly darker shade than the background color of the table. You can change this by calling setSortColumnBackgroundColor().

Returns:
the background color of the sort column

convertValueToText

public java.lang.String convertValueToText(java.lang.Object value,
                                           boolean isSelected,
                                           boolean hasFocus,
                                           int row,
                                           int column)
Called by the renderers to convert the specified value to text. This implementation returns null, ignoring all other arguments to indicate to the renderer to use the original value. To control the conversion, subclass this method and use any of the arguments you need.

Specified by:
convertValueToText in interface DisplayableTable
Parameters:
value - the Object to convert to text
isSelected - true if cell is selected
hasFocus - true if cell has focus
row - the row of the cell to render
column - the column of the cell to render
Returns:
the String representation of the node's value

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
Override to configure the scrollpane for this table.

Overrides:
configureEnclosingScrollPane in class javax.swing.JTable

unconfigureEnclosingScrollPane

protected void unconfigureEnclosingScrollPane()
Override to unconfigure the scrollpane for this table.

Overrides:
unconfigureEnclosingScrollPane in class javax.swing.JTable

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Override to provide a tooltip for cells that are obscured because they are too small to display their renderer properly. This functionality only really works well for tables where the objects in the cell have a sensible toString() method. If this isn't the case, you may want to switch this behavior off by calling setShowToolTips( false ).

Overrides:
getToolTipText in class javax.swing.JTable
Parameters:
event - mouse event to get tooltip for
Returns:
tooltip

getJTableToolTipText

protected java.lang.String getJTableToolTipText(java.awt.event.MouseEvent e)
Method for subclasses to call which want to avoid NiceTable functionality in getToolTipText(MouseEvent)

Parameters:
e -
Returns:
JTable.getToolTipText(MouseEvent)

getPreferredSize

public java.awt.Dimension getPreferredSize()
Override to return a height of 2 rows for the table when there are no elements in the table.

Overrides:
getPreferredSize in class javax.swing.JComponent

paintComponent

protected void paintComponent(java.awt.Graphics g)
Override the paint component to paint the background of the sorted column in a slightly different color from other columns. This method makes sure that the painting of this column extends into end of the table when there are only a small number of rows giving the illusion that the sort column continues to the bottom of the table. This works only when getFillsViewportHeight is true, which is turned on by default for this GenericTable.

Overrides:
paintComponent in class javax.swing.JComponent

setUI

public void setUI(javax.swing.plaf.TableUI ui)
Override to use the transferhandler that uses convertValueToText to copying the text.

Overrides:
setUI in class javax.swing.JTable

getDefaultRenderer

public javax.swing.table.TableCellRenderer getDefaultRenderer(java.lang.Class<?> columnClass)
Override to fix JDK bug if columnClass is null.

Overrides:
getDefaultRenderer in class javax.swing.JTable

selectAll

public void selectAll()
Stop cell editing when the user select all cells.

Overrides:
selectAll in class javax.swing.JTable

setColumnVisible

protected void setColumnVisible(javax.swing.table.TableColumn column,
                                int modelColumn,
                                boolean isVisible)
Makes the column visible it it can be hidden. Clients can controls which columns can be made visible by implementing GenericTableModel as their table model.


createDefaultRenderers

protected void createDefaultRenderers()
Override to creates default GenericTableCellRenderer for objects, numbers, doubles, dates, booleans, and icons. Also install the GenericTableHeaderRenderer for the table header

Overrides:
createDefaultRenderers in class javax.swing.JTable

installGenericTableRenderer

protected void installGenericTableRenderer()

processKeyBinding

protected boolean processKeyBinding(javax.swing.KeyStroke ks,
                                    java.awt.event.KeyEvent e,
                                    int condition,
                                    boolean pressed)
Overrides:
processKeyBinding in class javax.swing.JTable

scrollToSelection

public void scrollToSelection()
Scrolls the table's viewport to the currently selected row and column.


getPersistentSettings

public GenericTablePersistentSettings getPersistentSettings()
Get a javabean storing persistent settings of this NiceTable which you can serialize in order to restore the visible appearance of the table next time it is used. At the moment, the stored settings are:


setPersistentSettings

public void setPersistentSettings(GenericTablePersistentSettings settings)
Set the persistent view settings of this NiceTable.

Parameters:
settings -

setSorted

public void setSorted(boolean isSorted)
Set whether this GenericTable is sorted. If the table is sorted, a RowSorter will be set on the table.

Parameters:
isSorted - if true, the GenericTable is sorted.

setModel

public void setModel(javax.swing.table.TableModel dataModel)
Overrides:
setModel in class javax.swing.JTable

isSorted

public boolean isSorted()
Is the table sorted?


getSelectedRowInModel

public int getSelectedRowInModel()
Get the selected row as a model row, regardless of whether this table is currently sorted.

Returns:
the first row in the model that is selected.

getSelectedRowsInModel

public int[] getSelectedRowsInModel()
Get the selected rows as model rows, regardless of whether this table is currently sorted.

Returns:
an array of rows in the model that are selected.

setSelectedRowInModel

public void setSelectedRowInModel(int selectedRowInModel)
Select the specified model row, regardless of its position in the (sorted or unsorted) view.

Parameters:
selectedRowInModel - the model row to select.

setSelectedRowsInModel

public void setSelectedRowsInModel(int[] selectedRowsInModel)
Select the specified model rows, regardless of their position in the (sorted or unsorted) view.

Parameters:
selectedRowsInModel - the model rows to select.

setSortColumn

public void setSortColumn(int modelColumn,
                          boolean isSortAscending)
Set the column to sort the view by.

Parameters:
modelColumn - the column to sort by
isSortAscending - if true, the table is sorted in ascending order

reSort

public void reSort()
Convenience method that reapplies the current sort. You might want to use this after adding items to the table. It's just a shortcut for setSortColumn( getSortColumn(), isSortAscending() )


getDarker

protected static java.awt.Color getDarker(java.awt.Color c)
Get a very slightly darker shade of the specified color.

Parameters:
c - a color
Returns:
a very slightly darker shade of the color

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.