configureEnclosingScrollPane
protected void configureEnclosingScrollPane()
If this JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scroll pane. When a JTable is added to a JScrollPane in the usual way, using new JScrollPane(myTable), addNotify is called in the JTable (when the table is added to the viewport). JTable's addNotify method in turn calls this method, which is protected so that this default installation procedure can be overridden by a subclass.
See Also:
addNotify()
unconfigureEnclosingScrollPane
protected void unconfigureEnclosingScrollPane()
Reverses the effect of configureEnclosingScrollPane by replacing the columnHeaderView of the enclosing scroll pane with null. JTable's removeNotify method calls this method, which is protected so that this default uninstallation procedure can be overridden by a subclass.
- Since
- 1.3
See Also:
removeNotify(), configureEnclosingScrollPane()
setCellSelectionEnabled
public void setCellSelectionEnabled(boolean cellSelectionEnabled)
Sets whether this table allows both a column selection and a row selection to exist simultaneously. When set, the table treats the intersection of the row and column selection models as the selected cells. Override isCellSelected to change this default behavior. This method is equivalent to setting both the rowSelectionAllowed property and columnSelectionAllowed property of the columnModel to the supplied value.
- Parameters
- cellSelectionEnabled - true if simultaneous row and column selection is allowed
See Also:
getCellSelectionEnabled(), isCellSelected(int, int)
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. Most 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. Some UIs may need more functionality than this method provides, such as when manipulating the lead for discontiguous selection, and may not call into this method for some selection changes.
This implementation uses the following conventions:
- toggle: false, extend: false. Clear the previous selection and ensure the new cell is selected.
- toggle: false, extend: true. Extend the previous selection from the anchor to the specified cell, clearing all other selections.
- toggle: true, extend: false. If the specified cell is selected, deselect it. If it is not selected, select it.
- toggle: true, extend: true. Apply the selection state of the anchor to all cells between it and the specified cell.
- Parameters
- rowIndex - affects the selection at row
columnIndex - affects the selection at column
toggle - see description above
extend - if true, extend the current selection
- Since
- 1.3
createDefaultDataModel
protected TableModel createDefaultDataModel()
Returns the default table model object, which is a DefaultTableModel. A subclass can override this method to return a different table model object.
- Returns
- the default table model object
See Also:
DefaultTableModel
createDefaultColumnModel
protected TableColumnModel createDefaultColumnModel()
Returns the default column model object, which is a DefaultTableColumnModel. A subclass can override this method to return a different column model object.
- Returns
- the default column model object
See Also:
DefaultTableColumnModel
createDefaultSelectionModel
protected ListSelectionModel createDefaultSelectionModel()
Returns the default selection model object, which is a DefaultListSelectionModel. A subclass can override this method to return a different selection model object.
- Returns
- the default selection model object
See Also:
DefaultListSelectionModel
createDefaultTableHeader
protected JTableHeader createDefaultTableHeader()
Returns the default table header object, which is a JTableHeader. A subclass can override this method to return a different table header object.
- Returns
- the default table header object
See Also:
JTableHeader
getCellRenderer
public TableCellRenderer getCellRenderer(int row,
int column)
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.
- 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), setDefaultRenderer(java.lang.Class, javax.swing.table.TableCellRenderer)
prepareRenderer
public Component prepareRenderer(TableCellRenderer renderer,
int row,
int column)
Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.
During a printing operation, this method will configure the renderer without indicating selection or focus, to prevent them from appearing in the printed output. To do other customizations based on whether or not the table is being printed, you can check the value of JComponent.isPaintingForPrint(), either here or within custom renderers.
Note: Throughout the table package, the internal implementations always use this method to prepare renderers so that this default behavior can be safely overridden by a subclass.
- Parameters
- renderer - the TableCellRenderer to prepare
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 Component under the event location
getCellEditor
public TableCellEditor getCellEditor(int row,
int column)
Returns an appropriate editor for the cell specified by row and column. If the TableColumn for this column has a non-null editor, returns that. If not, finds the class of the data in this column (using getColumnClass) and returns the default editor for this type of data.
Note: Throughout the table package, the internal implementations always use this method to provide editors so that this default behavior can be safely overridden by a subclass.
- Parameters
- row - the row of the cell to edit, where 0 is the first row
column - the column of the cell to edit, where 0 is the first column
- Returns
- the editor for this cell; if null return the default editor for this type of cell
See Also:
DefaultCellEditor
prepareEditor
public Component prepareEditor(TableCellEditor editor,
int row,
int column)
Prepares the editor by querying the data model for the value and selection state of the cell at row, column.
Note: Throughout the table package, the internal implementations always use this method to prepare editors so that this default behavior can be safely overridden by a subclass.
- Parameters
- editor - the TableCellEditor to set up
row - the row of the cell to edit, where 0 is the first row
column - the column of the cell to edit, where 0 is the first column
- Returns
- the Component being edited