java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
org.jdesktop.swingx.JXTable
public class JXTable
This is a partial copy of JXTable javadoc. The focus is on stand-alone table fields/methods (their details section), that is those which are unreleated to cross-component themes. All summaries and unrelated field/method details are cut.
| Field Detail |
|---|
public static final String HORIZONTALSCROLL_ACTION_COMMAND
ActionMap.
public static final String PACKALL_ACTION_COMMAND
ActionMap.
public static final String PACKSELECTED_ACTION_COMMAND
ActionMap.
public static final String UIPREFIX
ResourceBundle.
public static final String MATCH_HIGHLIGHTER
protected FilterPipeline filters
protected HighlighterPipeline highlighters
protected Highlighter resetDefaultTableCellRendererHighlighter
protected ComponentAdapter dataAdapter
protected boolean isXTableRowHeightSet
adminSetRowHeight(int),
setRowHeight(int)protected Searchable searchable
| Constructor Detail |
|---|
public JXTable()
public JXTable(TableModel dm)
dm - The model to use.
public JXTable(TableModel dm,
TableColumnModel cm)
dm - The model to use.
public JXTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
dm - The table model to use.cm - The colomn model to use.sm - The list selection model to use.
public JXTable(int numRows,
int numColumns)
numRows - Count of rows to accomodate.numColumns - Count of columns to accomodate.
public JXTable(Vector rowData,
Vector columnNames)
rowData - Row data, as a Vector of Objects.columnNames - Column names, as a Vector of Strings.
public JXTable(Object[][] rowData,
Object[] columnNames)
rowData - Row data, as a two-dimensional Array of Objects (by row,
for column).columnNames - Column names, as a Array of Strings.| Method Detail |
|---|
public void setRolloverEnabled(boolean rolloverEnabled)
rolloverEnabled - protected JXTable.TableRolloverController getLinkController()
protected JXTable.TableRolloverController createLinkController()
protected RolloverProducer createRolloverProducer()
RolloverProducerpublic boolean isRolloverEnabled()
true if rollover is enabledpublic boolean isColumnControlVisible()
setColumnControlVisible(boolean),
setColumnControl(JComponent)public void setColumnControlVisible(boolean visible)
JXTable is contained in a JScrollPane, the
table adds the column control to the trailing corner of the scroll pane.
Note: if the table is not inside a JScrollPane the column
control is not shown even if this returns true. In this case it's the
responsibility of the client code to actually show it.
The default value is false.
visible - boolean to indicate if the column control should be shownisColumnControlVisible(),
setColumnControl(JComponent)public JComponent getColumnControl()
null.
setColumnControl(JComponent),
createDefaultColumnControl()public void setColumnControl(JComponent columnControl)
JScrollPane if appropriate. Passing a null
parameter restores the column control to the default.
The component is automatically visible only if the
columnControlVisible property is true and
the table is contained in a JScrollPane.
NOTE: from the table's perspective, the column control is simply a
JComponent to add to and keep in the trailing corner of
the scrollpane. (if any). It's up the concrete control to configure
itself from and keep synchronized to the columns' states.
columnControl - the JComponent to use as
columnControl.getColumnControl(),
createDefaultColumnControl(),
setColumnControlVisible(boolean)protected JComponent createDefaultColumnControl()
ColumnControlButton configured
with default ColumnControlIcon.
setColumnControl(JComponent),
ColumnControlButton,
ColumnControlIconpublic void setComponentOrientation(ComponentOrientation o)
Overridden to work around a core bug:
JScrollPane can't cope with
corners when changing component orientation at runtime.
This method explicitly re-configures the column control.
setComponentOrientation in class Componento - the ComponentOrientation for this table.Component.setComponentOrientation(ComponentOrientation)protected void configureEnclosingScrollPane()
JScrollPane. Overridden to addionally configure the upper trailing corner with the column control.
configureEnclosingScrollPane in class JTableconfigureColumnControl()protected void configureColumnControl()
JScrollPane.
Adds/removes the ColumnControl depending on the
columnControlVisible property.
setColumnControlVisible(boolean),
setColumnControl(JComponent)public void packAll()
By default this method is bound to the pack all columns
Action and registered in the table's ActionMap.
public void packSelected()
By default this method is bound to the pack selected column
Action and registered in the table's ActionMap.
public void columnSelectionChanged(ListSelectionEvent e)
TableColumnModel
is changed.
Application code will not use these methods explicitly, they are used internally by JTable.
Overridden to update the enabled state of the pack selected column
Action.
columnSelectionChanged in interface TableColumnModelListenercolumnSelectionChanged in class JTablee - the event receivedTableColumnModelListenerpublic void setHorizontalScrollEnabled(boolean enabled)
JViewport horizontally and shows the horizontal scrollbar if
necessary.
The default value is false.
PENDING JW: the name is mis-leading?
enabled - a boolean indicating whether enhanced auto-resize mode is
enabled.isHorizontalScrollEnabled()protected boolean isHorizontalScrollEnabled()
setHorizontalScrollEnabled(boolean)public void setAutoResizeMode(int mode)
Overridden for internal bookkeeping related to the enhanced auto-resize behaviour.
Note: to enable/disable the enhanced auto-resize mode use exclusively
setHorizontalScrollEnabled, this method can't cope with it.
setAutoResizeMode in class JTablemode - One of 5 legal values:
AUTO_RESIZE_OFF,
AUTO_RESIZE_NEXT_COLUMN,
AUTO_RESIZE_SUBSEQUENT_COLUMNS,
AUTO_RESIZE_LAST_COLUMN,
AUTO_RESIZE_ALL_COLUMNSsetHorizontalScrollEnabled(boolean)protected void updateHorizontalAction()
Action to
enablement of enhanced auto-resize behaviour.
public boolean getScrollableTracksViewportWidth()
autoResizeMode is set to
AUTO_RESIZE_OFF, which indicates that the
width of the viewport does not determine the width
of the table. Otherwise returns true. Overridden to support enhanced auto-resize behaviour enabled and necessary.
getScrollableTracksViewportWidth in interface ScrollablegetScrollableTracksViewportWidth in class JTableautoResizeMode is set
to AUTO_RESIZE_OFF, otherwise returns truesetHorizontalScrollEnabled(boolean)public void doLayout()
JTable's
columns is equal to the width of the table.
Before the layout begins the method gets the
resizingColumn of the tableHeader.
When the method is called as a result of the resizing of an enclosing window,
the resizingColumn is null. This means that resizing
has taken place "outside" the JTable and the change -
or "delta" - should be distributed to all of the columns regardless
of this JTable's automatic resize mode.
If the resizingColumn is not null, it is one of
the columns in the table that has changed size rather than
the table itself. In this case the auto-resize modes govern
the way the extra (or deficit) space is distributed
amongst the available columns.
The modes are:
Viewport. If the JTable is not
enclosed in a JScrollPane this may
leave parts of the table invisible.
JTable, including the one that is being
adjusted.
JTable makes adjustments
to the widths of the columns it respects their minimum and
maximum values absolutely. It is therefore possible that,
even after this method is called, the total width of the columns
is still not equal to the width of the table. When this happens
the JTable does not put itself
in AUTO_RESIZE_OFF mode to bring up a scroll bar, or break other
commitments of its current auto-resize mode -- instead it
allows its bounds to be set larger (or smaller) than the total of the
column minimum or maximum, meaning, either that there
will not be enough room to display all of the columns, or that the
columns will not fill the JTable's bounds.
These respectively, result in the clipping of some columns
or an area being painted in the JTable's
background color during painting.
The mechanism for distributing the delta amongst the available
columns is provided in a private method in the JTable
class:
adjustSizes(long targetSize, final Resizable3 r, boolean inverse)an explanation of which is provided in the following section.
Resizable3 is a private
interface that allows any data structure containing a collection
of elements with a size, preferred size, maximum size and minimum size
to have its elements manipulated by the algorithm.
Call "DELTA" the difference between the target size and the sum of the preferred sizes of the elements in r. The individual sizes are calculated by taking the original preferred sizes and adding a share of the DELTA - that share being based on how far each preferred size is from its limiting bound (minimum or maximum).
Call the individual constraints min[i], max[i], and pref[i].
Call their respective sums: MIN, MAX, and PREF.
Each new size will be calculated using:
size[i] = pref[i] + delta[i]
where each individual delta[i] is calculated according to:
If (DELTA < 0) we are in shrink mode where:
DELTA
delta[i] = ------------ * (pref[i] - min[i])
(PREF - MIN)
If (DELTA > 0) we are in expand mode where:
DELTA
delta[i] = ------------ * (max[i] - pref[i])
(MAX - PREF)
The overall effect is that the total size moves that same percentage, k, towards the total minimum or maximum and that percentage guarantees accomodation of the required space, DELTA.
Naive evaluation of the formulae presented here would be subject to
the aggregated rounding errors caused by doing this operation in finite
precision (using ints). To deal with this, the multiplying factor above,
is constantly recalculated and this takes account of the rounding
errors in the previous iterations. The result is an algorithm that
produces a set of integers whose values exactly sum to the supplied
targetSize, and does so by spreading the rounding
errors evenly over the given elements.
When targetSize is outside the [MIN, MAX] range,
the algorithm sets all sizes to their appropriate limiting value
(maximum or minimum).
Overridden to support enhanced auto-resize behaviour enabled and necessary.
doLayout in class JTablesetHorizontalScrollEnabled(boolean)public void columnMarginChanged(ChangeEvent e)
Application code will not use these methods explicitly, they are used internally by JTable.
Overridden to support enhanced auto-resize behaviour enabled and necessary.
columnMarginChanged in interface TableColumnModelListenercolumnMarginChanged in class JTablee - the event receivedsetHorizontalScrollEnabled(boolean)public void setFillsViewportHeight(boolean fillsViewportHeight)
The default value is true.
Note: this a backport from Mustang's JTable.
fillsViewportHeight - boolean to indicate whether the table should
always fill parent's height.getFillsViewportHeight(),
getScrollableTracksViewportHeight()public boolean getFillsViewportHeight()
setFillsViewportHeight(boolean),
getScrollableTracksViewportHeight()public boolean getScrollableTracksViewportHeight()
Overridden to control the tracksHeight property depending on fillsViewportHeight and relative size to containing parent.
getScrollableTracksViewportHeight in interface ScrollablegetScrollableTracksViewportHeight in class JTablesetFillsViewportHeight(boolean)public int getRowCount()
getRowCount in class JTableJTable.getColumnCount()public int convertRowIndexToModel(int row)
row - row index in view coordinates
public int convertRowIndexToView(int row)
row - row index in model coordinates
public Object getValueAt(int row,
int column)
row and column.
Note: The column is specified in the table view's display
order, and not in the TableModel's column
order. This is an important distinction because as the
user rearranges the columns in the table,
the column at a given index in the view will change.
Meanwhile the user's actions never affect the model's
column ordering.
getValueAt in class JTablerow - the row whose value is to be queriedcolumn - the column whose value is to be queried
public void setValueAt(Object aValue,
int row,
int column)
!isCellEditable(row, column).
Sets the value for the cell in the table model at row
and column.
Note: The column is specified in the table view's display
order, and not in the TableModel's column
order. This is an important distinction because as the
user rearranges the columns in the table,
the column at a given index in the view will change.
Meanwhile the user's actions never affect the model's
column ordering.
aValue is the new value.
setValueAt in class JTableaValue - the new valuerow - the row of the cell to be changedcolumn - the column of the cell to be changedisCellEditable(int, int)
public boolean isCellEditable(int row,
int column)
row and column
is editable. Otherwise, invoking setValueAt on the cell
will have no effect.
Overridden to account for row index mapping and to support a layered editability control:
JXTable.isEditable()
TableColumnExt.isEditable()
TableModel.isCellEditable()
isCellEditable in class JTablerow - the row index in view coordinatescolumn - the column index in view coordinates
setValueAt(Object, int, int),
isEditable(),
TableColumnExt.isEditable(),
TableModel.isCellEditable(int, int)public void setSelectionModel(ListSelectionModel newModel)
setSelectionModel in class JTablenewModel - the new selection modelJTable.getSelectionModel()public void setModel(TableModel newModel)
newModel and registers
with it for listener notifications from the new data model.
setModel in class JTablenewModel - the new data source for this tableJTable.getModel()public void tableChanged(TableModelEvent e)
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.
tableChanged in interface TableModelListenertableChanged in class JTableprotected boolean isDataChanged(TableModelEvent e)
e - the event to examine.
protected boolean isUpdate(TableModelEvent e)
e - the event to examine.
protected boolean isStructureChanged(TableModelEvent e)
e - the event to examine.
protected void updateViewSizeSequence()
public SelectionMapper getSelectionMapper()
SelectionMapperpublic FilterPipeline getFilters()
public void setFilters(FilterPipeline pipeline)
pipeline - the FilterPipeline to use, null removes
all filters.protected PipelineListener getFilterPipelineListener()
protected PipelineListener createPipelineListener()
protected void updateOnFilterContentChanged()
public void setSortable(boolean sortable)
sortable is
true then sorting will be enabled on all columns whose
sortable property is true. If
sortable is false then sorting will be
disabled for all columns, regardless of each column's individual
sorting property. The default is true.
sortable - boolean indicating whether or not this table supports sortable
columnsTableColumnExt.isSortable()public boolean isSortable()
public void resetSortOrder()
public void toggleSortOrder(int columnIndex)
The exact behaviour is defined by the SortController's toggleSortOrder implementation. Typically a unsorted column is sorted in ascending order, a sorted column's order is reversed.
Respects the tableColumnExt's sortable and comparator properties: routes the column's comparator to the SortController and does nothing if !isSortable(column).
PRE: 0 <= columnIndex < getColumnCount()
columnIndex - the columnIndex in view coordinates.protected boolean isSortable(int columnIndex)
Here: true if both this table and the column sortable property is enabled, false otherwise.
columnIndex - column in view coordinates
public void setSortOrder(int columnIndex,
SortOrder sortOrder)
PRE: 0 <= columnIndex < getColumnCount()
columnIndex - the column index in view coordinates.sortOrder - the sort order to use. If null or SortOrder.UNSORTED,
this method has the same effect as resetSortOrder();public SortOrder getSortOrder(int columnIndex)
columnIndex - the column index in view coordinates.
public void toggleSortOrder(Object identifier)
The exact behaviour is defined by the SortController's toggleSortOrder implementation. Typically a unsorted column is sorted in ascending order, a sorted column's order is reversed.
Respects the tableColumnExt's sortable and comparator properties: routes the column's comparator to the SortController and does nothing if !isSortable(column).
PENDING: JW - define the behaviour if the identifier is not found. This can happen if either there's no column at all with the identifier or if there's no column of type TableColumnExt. Currently does nothing, that is does not change sort state.
identifier - the column identifier.
public void setSortOrder(Object identifier,
SortOrder sortOrder)
PENDING: JW - define the behaviour if the identifier is not found. This can happen if either there's no column at all with the identifier or if there's no column of type TableColumnExt. Currently does nothing, that is does not change sort state.
identifier - the column's identifier.sortOrder - the sort order to use. If null or SortOrder.UNSORTED,
this method has the same effect as resetSortOrder();public SortOrder getSortOrder(Object identifier)
identifier - the column's identifier.
protected boolean isSortable(Object identifier)
Here: true if both this table and the column sortable property is enabled, false otherwise.
identifier - the column's identifier
protected SortController getSortController()
SortController may be nullpublic TableColumn getSortedColumn()
public void columnRemoved(TableColumnModelEvent e)
columnRemoved in interface TableColumnModelListenercolumnRemoved in class JTableTableColumnModelListenerpublic TableColumn getColumn(int viewColumnIndex)
TableColumn at view position
columnIndex. The return value is not null.
NOTE: This delegate method is added to protect developer's from
unexpected exceptions in jdk1.5+. Super does not expose the
TableColumn access by index which may lead to unexpected
IllegalArgumentException: If client code assumes the
delegate method is available, autoboxing will convert the given int to an
Integer which will call the getColumn(Object) method.
viewColumnIndex - index of the column with the object in question
TableColumn object that matches the column
index
ArrayIndexOutOfBoundsException - if viewColumnIndex out of allowed
range.JTable.getColumn(Object),
getColumnExt(int),
TableColumnModel.getColumn(int)public List<TableColumn> getColumns()
List of visible TableColumns.
List of visible columns.getColumns(boolean)public int getColumnMargin()
Convenience to expose column model properties through
JXTable api.
setColumnMargin(int),
TableColumnModel.getColumnMargin()public void setColumnMargin(int value)
JXTable api.
value - margin between columns; must be greater than or equal to
zero.getColumnMargin(),
TableColumnModel.setColumnMargin(int)public int getColumnCount(boolean includeHidden)
includeHidden is true or
false, respectively. If false, this method returns the same count as
getColumnCount(). If the columnModel is not of type
TableColumnModelExt, the parameter value has no effect.
includeHidden - a boolean to indicate whether invisible columns
should be included
JTable.getColumnCount(),
TableColumnModelExt.getColumnCount(boolean)public List<TableColumn> getColumns(boolean includeHidden)
List of contained TableColumns.
Includes or excludes invisible columns, depending on whether the
includeHidden is true or false, respectively. If false, an
Iterator over the List is equivalent to the
Enumeration returned by getColumns().
If the columnModel is not of type
TableColumnModelExt, the parameter value has no effect.
NOTE: the order of columns in the List depends on whether or not the invisible columns are included, in the former case it's the insertion order in the latter it's the current order of the visible columns.
includeHidden - a boolean to indicate whether invisible columns
should be included
List of contained columns.getColumns(),
TableColumnModelExt.getColumns(boolean)public TableColumnExt getColumnExt(Object identifier)
TableColumnExt with the given
identifier. The return value is null if there is no contained
column with identifier or if the column with identifier is not
of type TableColumnExt. The returned column
may be visible or hidden.
identifier - the object used as column identifier
TableColumnExt with the given identifier or
null if none is foundgetColumnExt(int),
JTable.getColumn(Object),
TableColumnModelExt.getColumnExt(Object)public TableColumnExt getColumnExt(int viewColumnIndex)
TableColumnExt at view position
columnIndex. The return value is null, if the column at
position columnIndex is not of type
TableColumnExt. The returned column is visible.
viewColumnIndex - the index of the column desired
TableColumnExt object that matches the column
index
ArrayIndexOutOfBoundsException - if columnIndex out of allowed
range, that is if
(columnIndex < 0) || (columnIndex >= getColumnCount()).getColumnExt(Object),
getColumn(int),
TableColumnModelExt.getColumnExt(int)public void setColumnSequence(Object[] identifiers)
identifiers - array of logical column namesgetColumns(boolean)public void createDefaultColumnsFromModel()
TableColumns for
columns in this table's TableModel. Removes all currently
contained TableColumns. The exact type and configuration
of the columns is controlled by the ColumnFactory.
createDefaultColumnsFromModel in class JTableColumnFactorypublic ColumnFactory getColumnFactory()
setColumnFactory(ColumnFactory),
ColumnFactorypublic void setColumnFactory(ColumnFactory columnFactory)
ColumnFactory to use for column creation and
configuration. The default value is the shared application
ColumnFactory.
columnFactory - the factory to use, null indicates
to use the shared application factory.getColumnFactory(),
ColumnFactorypublic void packTable(int margin)
margin - the margin to apply to each column.packColumn(int, int),
packColumn(int, int, int)
public void packColumn(int column,
int margin)
column - The Column index to pack in View Coordinatesmargin - The Margin to apply to the column width.packColumn(int, int, int),
packTable(int)
public void packColumn(int column,
int margin,
int max)
column - the column index to pack in view coordinatesmargin - the margin to apply to the columnmax - the maximum width the column can be resized to, -1 means no limitpackColumn(int, int),
packTable(int),
ColumnFactory.packColumn(JXTable, TableColumnExt, int, int)public int getVisibleRowCount()
JScrollPane.
JScrollPanesetVisibleRowCount(int)public void setVisibleRowCount(int visibleRowCount)
JScrollPane.
TODO JW - make bound property, reset scrollablePref(? distinguish internal from client code triggered like in rowheight?) and re-layout.
visibleRowCount - number of rows to show in a JScrollPanegetVisibleRowCount()public Dimension getPreferredScrollableViewportSize()
TODO JW: refactor and comment.
getPreferredScrollableViewportSize in interface ScrollablegetPreferredScrollableViewportSize in class JTableDimension object containing the preferredSize of the JViewport
which displays this tableScrollable.getPreferredScrollableViewportSize()protected void initializeColumnPreferredWidth(TableColumn column)
TableColumnExt or prototypeValue is null
then the preferredWidth is left unmodified.
TODO JW - need to cleanup getScrollablePreferred (refactor and inline) update doc - what exactly happens is left to the columnfactory.
column - TableColumn object representing view columnTableColumnExt.setPrototypeValue(java.lang.Object)public void scrollRowToVisible(int row)
JViewport.
Note: this method has no precondition as it internally uses
getCellRect which is lenient to off-range coordinates.
row - the view row index of the cellscrollColumnToVisible(int),
scrollCellToVisible(int, int),
JComponent.scrollRectToVisible(Rectangle)public void scrollColumnToVisible(int column)
JViewport.
Note: this method has no precondition as it internally uses
getCellRect which is lenient to off-range coordinates.
column - the view column index of the cellscrollRowToVisible(int),
scrollCellToVisible(int, int),
JComponent.scrollRectToVisible(Rectangle)
public void scrollCellToVisible(int row,
int column)
JViewport.
Note: this method has no precondition as it internally uses
getCellRect which is lenient to off-range coordinates.
row - the view row index of the cellcolumn - the view column index of the cellscrollColumnToVisible(int),
scrollRowToVisible(int),
JComponent.scrollRectToVisible(Rectangle)public int getSelectionMode()
PENDING JW - setter?
ListSelectionModel.getSelectionMode()public Searchable getSearchable()
public void setSearchable(Searchable searchable)
searchable - protected ComponentAdapter getComponentAdapter()
protected ComponentAdapter getComponentAdapter(int row,
int column)
row - the row index in view coordinates.column - the column index in view coordinates.
public HighlighterPipeline getHighlighters()
setHighlighters(HighlighterPipeline)public void setHighlighters(HighlighterPipeline pipeline)
The default value is null.
pipeline - the HighlighterPipeline to use for renderer decoration.getHighlighters(),
addHighlighter(Highlighter),
removeHighlighter(Highlighter)public void addHighlighter(Highlighter highlighter)
If the HighlighterPipeline returned from getHighlighters()
is null, creates and sets a new pipeline containing the given
Highlighter. Else, appends the Highlighter
to the end of the pipeline.
highlighter - the Highlighter to add.
NullPointerException - if Highlighter is null.removeHighlighter(Highlighter),
setHighlighters(HighlighterPipeline)public void removeHighlighter(Highlighter highlighter)
Does nothing if the HighlighterPipeline is null or does not contain the given Highlighter.
highlighter - the highlighter to remove.addHighlighter(Highlighter),
setHighlighters(HighlighterPipeline)protected ChangeListener getHighlighterChangeListener()
ChangeListener to use with highlighters. Lazily
creates the listener.
not-nullprotected ChangeListener createHighlighterChangeListener()
Here: repaints the table on receiving a stateChanged.
public TableCellRenderer getCellRenderer(int row,
int column)
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.
Overridden to fix core bug #4614616 (NPE if TableModel's
Class for the column is an interface). This method
guarantees to always return a not null value. Returns the
default renderer for Object if super returns
null.
getCellRenderer in class JTablerow - the row of the cell to render, where 0 is the first rowcolumn - the column of the cell to render,
where 0 is the first column
null
returns the default renderer
for this type of objectDefaultTableCellRenderer,
TableColumn.setCellRenderer(javax.swing.table.TableCellRenderer),
JTable.setDefaultRenderer(java.lang.Class>, javax.swing.table.TableCellRenderer)
public Component prepareRenderer(TableCellRenderer renderer,
int row,
int column)
Component used as a stamp to render
the specified cell. Overrides superclass version to provide support for
cell decorators.
Adjusts component orientation (guaranteed to happen before applying Highlighters).
prepareRenderer in class JTablerenderer - the TableCellRenderer to preparerow - the row of the cell to render, where 0 is the first rowcolumn - the column of the cell to render, where 0 is the first
column
Component used as a stamp to render
the specified cellHighlighter
protected void resetDefaultTableCellRendererColors(Component renderer,
int row,
int column)
Highlighter
to force reset the color "memory" of DefaultTableCellRenderer.
This is called for each renderer in prepareRenderer after
calling super, but before applying the HighlighterPipeline. Subclasses
which are sure to solve the problem at the core (that is in
a well-behaved DefaultTableCellRenderer) should override this method
to do nothing.
renderer - the TableCellRenderer to hackrow - the row of the cell to rendercolumn - the column index of the cell to renderResetDTCRColorHighlighter,
prepareRenderer(TableCellRenderer, int, int)
public Component prepareEditor(TableCellEditor editor,
int row,
int column)
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.
Overridden to adjust the editor's component orientation.
prepareEditor in class JTableeditor - the TableCellEditor to set uprow - the row of the cell to edit,
where 0 is the first rowcolumn - the column of the cell to edit,
where 0 is the first column
Component being editedprotected void adjustComponentOrientation(Component stamp)
Component's orientation to this
JXTable's CO if appropriate. The parameter must not be
null.
This implementation synchs the CO always.
stamp - the Component who's CO may need to be synched,
must not be null.public TableCellRenderer getNewDefaultRenderer(Class columnClass)
getDefaultRenderer() in that it returns
a new instance each time so that the renderer may be set and
customized on a particular column.
columnClass - Class of value being rendered
JTable.getDefaultRenderer(Class)protected void createDefaultRenderers()
Overridden so we can act as factory for renderers plus hacking around huge memory consumption of UIDefaults (see #6345050 in core Bug parade)
Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.
createDefaultRenderers in class JTableDefaultTableCellRendererprotected void createDefaultEditors()
Overridden to hook enhanced editors plus hacking around huge memory consumption of UIDefaults (see #6345050 in core Bug parade)
createDefaultEditors in class JTableDefaultCellEditorpublic boolean isEditable()
JXTable as a whole.
setEditable(boolean)public void setEditable(boolean editable)
TableColumnExt.isEditable and their per-cell
editability as returned by the TableModel.isCellEditable.
If a cell is read-only in its column or model layer, this property has no
effect.
The default value is true.
editable - the flag to indicate if the table is editable.isEditable(),
isCellEditable(int, int)public boolean isTerminateEditOnFocusLost()
setTerminateEditOnFocusLost(boolean)public void setTerminateEditOnFocusLost(boolean terminate)
JTable.CellEditorRemover: "outside" is
interpreted to be on a component which is not under the table hierarchy
but inside the same toplevel window, "terminate" does so in any case,
first tries to stop the edit, if that's unsuccessful it cancels the edit.
The default value is true.
terminate - the flag to determine whether or not to terminate the
editisTerminateEditOnFocusLost()public boolean isAutoStartEditOnKeyStroke()
setAutoStartEditOnKeyStroke(boolean)public void setAutoStartEditOnKeyStroke(boolean autoStart)
The default value is true.
autoStart - boolean to determine whether a keyStroke should try to
start editing.isAutoStartEditOnKeyStroke()public void updateUI()
UIManager that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager.
Additionally updates auto-adjusted row height and highlighters.
Another of the override motivation is to fix core issue (?? ID): super fails to update all renderers/editors.
updateUI in class JTableJComponent.updateUI()protected void updateHighlighterUI()
updateUI changes.
Highlighter.UIHighlighterprotected void updateRowHeightUI(boolean respectRowSetFlag)
true and the rowHeight
had been already set by client code. The underlying problem is that raw
types can't implement UIResource.
This implementation asks the UIManager for a default value (stored with key "JXTable.rowHeight"). If none is available, calculates a "reasonable" height from the table's fontMetrics, assuming that most renderers/editors will have a border with top/bottom of 1.
respectRowSetFlag - a boolean to indicate whether client-code flag
should be respected.isXTableRowHeightSet
public void setDefaultMargins(boolean showHorizontalLines,
boolean showVerticalLines)
showHorizontalLines - boolean to decide whether to draw horizontal
grid lines.showVerticalLines - boolean to decide whether to draw vertical grid
lines.
public void setShowGrid(boolean showHorizontalLines,
boolean showVerticalLines)
showHorizontalLines - boolean to decide whether to draw horizontal
grid lines.showVerticalLines - boolean to decide whether to draw vertical grid
lines.JTable.setShowGrid(boolean),
JTable.setIntercellSpacing(Dimension)public void setRowHeight(int rowHeight)
rowHeight,
revalidates, and repaints.
The height of the cells will be equal to the row height minus
the row margin.
Overriden to keep view/model coordinates of SizeSequence in synch. Marks the request as client-code induced.
setRowHeight in class JTablerowHeight - new row heightisXTableRowHeightSet
public void setRowHeight(int row,
int rowHeight)
row to rowHeight,
revalidates, and repaints. The height of the cells in this row
will be equal to the row height minus the row margin.
Does nothing if support of individual rowHeights is not enabled. Overriden to keep view/model coordinates of SizeSequence in synch.
setRowHeight in class JTablerow - the row whose height is being
changedrowHeight - new row height, in pixelsisRowHeightEnabled()public void setRowHeightEnabled(boolean enabled)
The default value is false.
enabled - a boolean to indicate whether per-row heights should be
enabled.isRowHeightEnabled(),
setRowHeight(int, int)public boolean isRowHeightEnabled()
setRowHeightEnabled(boolean),
setRowHeight(int, int)protected SizeSequenceMapper getRowModelMapper()
SizeSequenceMapper used to synch view/model
coordinates for individual row heightsSizeSequenceMapperprotected void adminSetRowHeight(int rowHeight)
isXTableRowHeight unchanged. This enables the distinction
between setting the height for internal reasons from doing so by client
code.
rowHeight - new height in pixel.setRowHeight(int),
isXTableRowHeightSetpublic int rowAtPoint(Point point)
point lies in,
or -1 if the result is not in the range
[0, getRowCount()-1].
Overridden to work around core Bug (ID #6291631): negative y is mapped to row 0).
rowAtPoint in class JTablepoint - the location of interest
point lies in,
or -1 if the result is not in the range
[0, getRowCount()-1]JTable.columnAtPoint(java.awt.Point)protected JTableHeader createDefaultTableHeader()
JTableHeader. A subclass can override this
method to return a different table header object.
Overridden to return a JXTableHeader.
createDefaultTableHeader in class JTableJXTableHeaderprotected TableColumnModel createDefaultColumnModel()
DefaultTableColumnModel. A subclass can override this
method to return a different column model object.
Overridden to return a DefaultTableColumnModelExt.
createDefaultColumnModel in class JTableDefaultTableColumnModelExt
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||