|
swingx Version 2009-07-31 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
org.jdesktop.swingx.JXTable
public class JXTable
Enhanced Table component with support for general SwingX sorting/filtering, rendering, highlighting, rollover and search functionality. Table specific enhancements include runtime configuration options like toggle column visibility, column sizing, PENDING JW ...
table.setSortOrder("PERSON_ID", SortOrder.DESCENDING);
table.toggleSortOder(4);
table.resetSortOrder();
Sorting sequence can be configured per column by setting the TableColumnExt's
comparator
property. Sorting can be disabled per column - setting the TableColumnExt's
sortable
or per table by setSortable(boolean)
.
The table takes responsibility to propagate these
properties to the current sorter, if available Note that the enhanced sorting controls are effective only if the RowSorter is of type SortController, which it is by default. Different from core JTable, the autoCreateRowSorter property is enabled by default. If on, the JXTable creates and uses a default row sorter as returned by the createDefaultRowSorter method.
Typically, a JXTable is sortable by left clicking on column headers. By default, each subsequent click on a header reverses the order of the sort, and a sort arrow icon is automatically drawn on the header.
An example multiple highlighting (default striping as appropriate for the current LookAndFeel, cell foreground on matching pattern, and shading a column):
Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
PatternPredicate patternPredicate = new PatternPredicate("ˆM", 1);
ColorHighlighter magenta = new ColorHighlighter(patternPredicate, null,
Color.MAGENTA, null, Color.MAGENTA);
Highlighter shading = new ShadingColorHighlighter(
new HighlightPredicate.ColumnHighlightPredicate(1));
table.setHighlighters(simpleStriping,
magenta,
shading);
To fully support, JXTable registers SwingX default table renderers instead of
core defaults (see DefaultTableRenderer
) The recommended approach for
customizing rendered content it to intall a DefaultTableRenderer configured
with a custom String- and/or IconValue. F.i. assuming the cell value is a
File and should be rendered by showing its name followed and date of last
change:
StringValue sv = new StringValue() {
public String getString(Object value) {
if (!(value instanceof File)) return StringValues.TO_STRING.getString(value);
return StringValues.FILE_NAME.getString(value) + ", "
+ StringValues.DATE_TO_STRING.getString(((File) value).lastModified());
}};
table.setCellRenderer(File.class, new DefaultTableRenderer(sv));
Note: DefaultTableCellRenderer and subclasses require a hack to play
nicely with Highlighters because it has an internal "color memory" in
setForeground/setBackground. The hack is applied by default which might lead
to unexpected side-effects in custom renderers subclassing DTCR. See
resetDefaultTableCellRendererHighlighter
for details.
JXTable table = new JXTable();
table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW,
null, Color.RED);
JXTable provides api to vend a renderer-controlled String representation of cell content. This allows the Searchable and Highlighters to use WYSIWYM (What-You-See-Is-What-You-Match), that is pattern matching against the actual string as seen by the user.
Columns can be hidden or shown by setting the visible property on the
TableColumnExt using TableColumnExt.setVisible(boolean)
. Columns can
also be shown or hidden from the column control popup.
The column control popup is triggered by an icon drawn to the far right of
the column headers, above the table's scrollbar (when installed in a
JScrollPane). The popup allows the user to select which columns should be
shown or hidden, as well as to pack columns and turn on horizontal scrolling.
To show or hide the column control, use the
setColumnControlVisible(boolean show)
method.
You can resize all columns, selected columns, or a single column using the
methods like packAll()
. Packing combines several other aspects of a
JXTable. If horizontal scrolling is enabled using
setHorizontalScrollEnabled(boolean)
, then the scrollpane will allow
the table to scroll right-left, and columns will be sized to their preferred
size. To control the preferred sizing of a column, you can provide a
prototype value for the column in the TableColumnExt using
TableColumnExt.setPrototypeValue(Object)
. The prototype is used as an
indicator of the preferred size of the column. This can be useful if some
data in a given column is very long, but where the resize algorithm would
normally not pick this up.
Keys/Actions registered with this component:
HORIZONTALSCROLL_ACTION_COMMAND
- toggle the horizontal
scrollbar
PACKSELECTED_ACTION_COMMAND
- resize the selected column
to fit the widest cell content
PACKALL_ACTION_COMMAND
- resize all columns to fit the
widest cell content in each column
Key bindings.
Client Properties.
MATCH_HIGHLIGHTER
- set to Boolean.TRUE to use a
SearchHighlighter to mark a cell as matching.
Nested Class Summary | |
---|---|
static class |
JXTable.BooleanEditor
The default editor for Boolean types. |
static class |
JXTable.GenericEditor
Default editor registered for Object . |
static class |
JXTable.NumberEditor
Editor for Number s. |
protected static class |
JXTable.TableAdapter
|
Nested classes/interfaces inherited from class javax.swing.JTable |
---|
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected CompoundHighlighter |
compoundHighlighter
The CompoundHighlighter for the table. |
protected ComponentAdapter |
dataAdapter
The ComponentAdapter for model data access. |
protected org.jdesktop.swingx.JXTable.CellEditorRemover |
editorRemover
|
static String |
FOCUS_NEXT_COMPONENT
|
static String |
FOCUS_PREVIOUS_COMPONENT
|
static String |
HORIZONTALSCROLL_ACTION_COMMAND
Identifier of show horizontal scroll action, used in JXTable's ActionMap . |
protected boolean |
isXTableRowHeightSet
Flag to distinguish internal settings of row height from client code settings. |
static String |
MATCH_HIGHLIGHTER
key for client property to use SearchHighlighter as match marker. |
static String |
PACKALL_ACTION_COMMAND
Identifier of pack table action, used in JXTable's ActionMap
. |
static String |
PACKSELECTED_ACTION_COMMAND
Identifier of pack selected column action, used in JXTable's ActionMap . |
protected Highlighter |
resetDefaultTableCellRendererHighlighter
The Highlighter used to hack around DefaultTableCellRenderer's color memory. |
protected Searchable |
searchable
property to control search behaviour. |
static String |
UIPREFIX
The prefix marker to find table related properties in the ResourceBundle . |
static String |
USE_DTCR_COLORMEMORY_HACK
The key for the client property deciding about whether the color memory hack for DefaultTableCellRenderer should be used. |
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 | |
---|---|
JXTable()
Instantiates a JXTable with a default table model, no data. |
|
JXTable(int numRows,
int numColumns)
Instantiates a JXTable for a given number of columns and rows. |
|
JXTable(Object[][] rowData,
Object[] columnNames)
Instantiates a JXTable with data in a array or rows and column names. |
|
JXTable(TableModel dm)
Instantiates a JXTable with a specific table model. |
|
JXTable(TableModel dm,
TableColumnModel cm)
Instantiates a JXTable with a specific table model. |
|
JXTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
Instantiates a JXTable with a specific table model, column model, and selection model. |
|
JXTable(Vector rowData,
Vector columnNames)
Instantiates a JXTable with data in a vector or rows and column names. |
Method Summary | |
---|---|
void |
addHighlighter(Highlighter highlighter)
Appends a Highlighter to the end of the list of used
Highlighter s. |
protected void |
adjustComponentOrientation(Component stamp)
Adjusts the Component 's orientation to this
JXTable 's CO if appropriate. |
protected void |
adminSetRowHeight(int rowHeight)
Sets the rowHeight for all rows to the given value. |
void |
columnAdded(TableColumnModelEvent e)
Overridden to propagate sort-related column properties to the SortController. |
void |
columnMarginChanged(ChangeEvent e)
Overridden to support enhanced auto-resize behaviour enabled and necessary. |
void |
columnPropertyChange(PropertyChangeEvent event)
Notifies listeners about property changes of contained columns. |
void |
columnSelectionChanged(ListSelectionEvent e)
Overridden to update the enabled state of the pack selected column Action . |
protected void |
configureColumnControl()
Configures the upper trailing corner of an enclosing JScrollPane . |
protected void |
configureEnclosingScrollPane()
Configures the enclosing JScrollPane . |
protected void |
configureSorterProperties()
Propagates sort-related properties from table/columns to the sorter if it is of type SortController, does nothing otherwise. |
protected JComponent |
createDefaultColumnControl()
Creates the default column control used by this table. |
protected TableColumnModel |
createDefaultColumnModel()
Overridden to return a DefaultTableColumnModelExt . |
void |
createDefaultColumnsFromModel()
Creates, configures and adds default TableColumn s for
columns in this table's TableModel . |
protected void |
createDefaultEditors()
Creates default cell editors for objects, numbers, and boolean values. |
protected void |
createDefaultRenderers()
Creates default cell renderers for Object s,
Number s, Date s, Boolean s, and
Icon/Image/ s. |
protected RowSorter<? extends TableModel> |
createDefaultRowSorter()
Creates and returns the default RowSorter. |
protected JTableHeader |
createDefaultTableHeader()
Overridden to return a JXTableHeader . |
protected ChangeListener |
createHighlighterChangeListener()
Creates and returns the ChangeListener observing Highlighters. |
protected TableRolloverController<JXTable> |
createLinkController()
Creates and returns a RolloverController appropriate for this component. |
protected RolloverProducer |
createRolloverProducer()
Creates and returns the RolloverProducer to use with this component. |
protected void |
doFind()
Starts a search on this List's visible items. |
void |
doLayout()
Layouts column width. |
boolean |
editCellAt(int row,
int column,
EventObject e)
overridden to install a custom editor remover. |
boolean |
getAutoCreateColumnsFromModel()
Overridden for documentation clarification. |
boolean |
getAutoCreateRowSorter()
Overridden to return xflag |
TableCellRenderer |
getCellRenderer(int row,
int column)
Overridden to fix core bug #4614616 (NPE if TableModel 's
Class for the column is an interface). |
TableColumn |
getColumn(int viewColumnIndex)
Returns the TableColumn at view position
columnIndex . |
JComponent |
getColumnControl()
Returns the component used as column control. |
int |
getColumnCount(boolean includeHidden)
Returns the number of contained columns. |
TableColumnExt |
getColumnExt(int viewColumnIndex)
Returns the TableColumnExt at view position
columnIndex . |
TableColumnExt |
getColumnExt(Object identifier)
Returns the first TableColumnExt with the given
identifier . |
ColumnFactory |
getColumnFactory()
Returns the ColumnFactory. |
int |
getColumnMargin()
Returns the margin between columns. |
List<TableColumn> |
getColumns()
Returns a List of visible TableColumn s. |
List<TableColumn> |
getColumns(boolean includeHidden)
Returns a List of contained TableColumn s. |
protected ComponentAdapter |
getComponentAdapter()
|
protected ComponentAdapter |
getComponentAdapter(int row,
int column)
Convenience to access a configured ComponentAdapter. |
protected CompoundHighlighter |
getCompoundHighlighter()
Returns the CompoundHighlighter assigned to the table, null if none. |
protected ChangeListener |
getHighlighterChangeListener()
Returns the ChangeListener to use with highlighters. |
Highlighter[] |
getHighlighters()
Returns the Highlighter s used by this table. |
protected TableRolloverController<JXTable> |
getLinkController()
Returns the RolloverController for this component. |
TableCellRenderer |
getNewDefaultRenderer(Class<?> columnClass)
Returns a new instance of the default renderer for the specified class. |
Dimension |
getPreferredScrollableViewportSize()
Overridden to support auto-calculation of pref scrollable size, dependent on the visible row/column count properties. |
boolean |
getScrollableTracksViewportWidth()
Overridden to support enhanced auto-resize behaviour enabled and necessary. |
Searchable |
getSearchable()
Returns a Searchable for this component, guaranteed to be not null. |
int |
getSelectionMode()
Returns the selection mode used by this table's selection model. |
protected SortController |
getSortController()
Returns the currently active SortController. |
TableColumn |
getSortedColumn()
Returns the primary sort column, or null if nothing sorted or no sortKey corresponds to a TableColumn currently contained in the TableColumnModel. |
SortOrder |
getSortOrder(int columnIndex)
Returns the SortOrder of the given column. |
SortOrder |
getSortOrder(Object identifier)
Returns the SortOrder of the given column. |
boolean |
getSortsOnUpdates()
Returns true if a sort should happen when the underlying model is updated; otherwise, returns false. |
String |
getStringAt(int row,
int column)
Returns the string representation of the cell value at the given position. |
protected String |
getUIString(String key)
Returns a potentially localized value from the UIManager. |
protected String |
getUIString(String key,
Locale locale)
Returns a potentially localized value from the UIManager for the given locale. |
int |
getVisibleColumnCount()
Returns the preferred number of columns to show in the JScrollPane . |
int |
getVisibleRowCount()
Returns the preferred number of rows to show in a JScrollPane . |
protected void |
initializeColumnPreferredWidth(TableColumn column)
Initialize the width related properties of the specified column. |
protected void |
initializeColumnWidths()
Initialize the width related properties of all contained TableColumns, both visible and hidden. |
boolean |
isAutoStartEditOnKeyStroke()
Returns the autoStartsEdit property. |
boolean |
isCellEditable(int row,
int column)
Returns true if the cell at row and column is
editable. |
boolean |
isColumnControlVisible()
Returns the column control visible property. |
protected boolean |
isDataChanged(TableModelEvent e)
Convenience method to detect dataChanged table event type. |
boolean |
isEditable()
Returns the editable property of the JXTable as a whole. |
boolean |
isFocusCycleRoot()
Overridden to prevent spurious focus loss to outside of table while removing the editor. |
boolean |
isHorizontalScrollEnabled()
Returns the current setting for horizontal scrolling. |
boolean |
isRolloverEnabled()
Returns a boolean indicating whether or not rollover support is enabled. |
boolean |
isRowHeightEnabled()
Deprecated. no longer necessary (switched to 1.6) |
boolean |
isSortable()
Returns the table's sortable property. |
protected boolean |
isSortable(int columnIndex)
Decides if the column at columnIndex can be interactively sorted. |
protected boolean |
isSortable(Object identifier)
Decides if the column with identifier can be interactively sorted. |
protected boolean |
isStructureChanged(TableModelEvent e)
Convenience method to detect a structureChanged table event type. |
boolean |
isTerminateEditOnFocusLost()
Returns the property which determines the edit termination behaviour on focus lost. |
protected boolean |
isUpdate(TableModelEvent e)
Convenience method to detect update table event type. |
void |
packAll()
Resizes all columns to fit their content. |
void |
packColumn(int column,
int margin)
Packs an indivudal column in the table. |
void |
packColumn(int column,
int margin,
int max)
Packs an indivual column in the table to less than or equal to the maximum witdth. |
void |
packSelected()
Resizes the lead column to fit its content. |
void |
packTable(int margin)
Packs all the columns to their optimal size. |
Component |
prepareEditor(TableCellEditor editor,
int row,
int column)
Overridden to adjust the editor's component orientation. |
Component |
prepareRenderer(TableCellRenderer renderer,
int row,
int column)
Returns the decorated Component used as a stamp to render
the specified cell. |
void |
removeEditor()
Overridden with backport from Mustang fix for #4684090, #4887999. |
void |
removeHighlighter(Highlighter highlighter)
Removes the given Highlighter. |
void |
removeNotify()
Overridden to uninstall the custom editor remover. |
protected void |
resetDefaultTableCellRendererColors(Component renderer,
int row,
int column)
Method to apply a hack around DefaultTableCellRenderer "color memory" (Issue #258-swingx). |
void |
resetSortOrder()
Resets sorting of all columns. |
int |
rowAtPoint(Point point)
Overridden to work around core Bug (ID #6291631): negative y is mapped to row 0). |
void |
scrollCellToVisible(int row,
int column)
Scrolls to make the cell at row and column visible. |
void |
scrollColumnToVisible(int column)
Scrolls horizontally to make the given column visible. |
void |
scrollRowToVisible(int row)
Scrolls vertically to make the given row visible. |
void |
setAutoCreateRowSorter(boolean autoCreateRowSorter)
Overridden to fix core bug: replaces sorter even if flag doesn't change. |
void |
setAutoResizeMode(int mode)
Overridden for internal bookkeeping related to the enhanced auto-resize behaviour. |
void |
setAutoStartEditOnKeyStroke(boolean autoStart)
Sets the autoStartsEdit property. |
void |
setColumnControl(JComponent columnControl)
Sets the component used as column control. |
void |
setColumnControlVisible(boolean visible)
Sets the column control visible property. |
void |
setColumnFactory(ColumnFactory columnFactory)
Sets the ColumnFactory to use for column creation and
configuration. |
void |
setColumnMargin(int value)
Sets the margin between columns. |
void |
setColumnModel(TableColumnModel columnModel)
Overridden to synch sorter state from columns. |
void |
setColumnSequence(Object[] identifiers)
Reorders the columns in the sequence given array. |
void |
setComponentOrientation(ComponentOrientation o)
Sets the language-sensitive orientation that is to be used to order the elements or text within this component. |
void |
setEditable(boolean editable)
Sets the editable property. |
void |
setFillsViewportHeight(boolean fillsViewportHeight)
Overridden for documentation reasons only: same behaviour but different default value. |
void |
setGridColor(Color gridColor)
Overridden because super throws NPE on null param. |
void |
setHighlighters(Highlighter... highlighters)
Sets the Highlighter s to the table, replacing any old
settings. |
void |
setHorizontalScrollEnabled(boolean enabled)
Sets the enablement of enhanced horizontal scrolling. |
void |
setLocale(Locale locale)
Overridden to update locale-dependent properties. |
void |
setModel(TableModel dataModel)
Overridden to prevent super from creating RowSorter. |
void |
setPreferredScrollableViewportSize(Dimension size)
If the given dimension is null, the auto-calculation of the pref scrollable size is enabled, otherwise the behaviour is the same as super. |
void |
setRolloverEnabled(boolean rolloverEnabled)
Sets the property to enable/disable rollover support. |
void |
setRowHeight(int rowHeight)
Overriden to mark the request as client-code induced. |
void |
setRowHeightEnabled(boolean enabled)
Deprecated. no longer necessary (switched to 1.6) |
void |
setRowSorter(RowSorter<? extends TableModel> sorter)
Overridden propagate sort-related properties to the sorter after calling super, if the given RowSorter is of type SortController. |
void |
setSearchable(Searchable searchable)
Sets the Searchable for this table. |
void |
setSelectionBackground(Color selectionBackground)
Overridden because super throws NPE on null param. |
void |
setSelectionForeground(Color selectionForeground)
Overridden because super throws NPE on null param. |
void |
setShowGrid(boolean showGrid)
Behaves exactly like super. |
void |
setShowGrid(boolean showHorizontalLines,
boolean showVerticalLines)
Convenience to set both grid line visibility and default margin for horizontal/vertical lines. |
void |
setSortable(boolean sortable)
Sets "sortable" property indicating whether or not this table supports sortable columns. |
void |
setSortOrder(int columnIndex,
SortOrder sortOrder)
Sorts the table by the given column using SortOrder. |
void |
setSortOrder(Object identifier,
SortOrder sortOrder)
Sorts the table by the given column using the SortOrder. |
void |
setSortsOnUpdates(boolean sortsOnUpdates)
If true, specifies that a sort should happen when the underlying model is updated ( rowsUpdated is invoked). |
void |
setTerminateEditOnFocusLost(boolean terminate)
Sets the property to determine whether an ongoing edit should be terminated if the focus is moved to somewhere outside of the table. |
void |
setValueAt(Object aValue,
int row,
int column)
Overridden to account for row index mapping. |
void |
setVisibleColumnCount(int visibleColumnCount)
Sets the preferred number of Columns to show in a JScrollPane . |
void |
setVisibleRowCount(int visibleRowCount)
Sets the preferred number of rows to show in a JScrollPane . |
void |
tableChanged(TableModelEvent e)
Overridden to re-calculate intialize column width and preferred scrollable size after a structureChanged if autocreateColumnsFromModel is true. |
void |
toggleSortOrder(int columnIndex)
Toggles the sort order of the column at columnIndex. |
void |
toggleSortOrder(Object identifier)
Toggles the sort order of the column with identifier. |
void |
transferFocus()
Overridden to try to stop the edit, if appropriate. |
void |
transferFocusBackward()
Overridden to try to stop the edit, if appropiate. |
protected void |
unconfigureColumnControl()
/** Unconfigures the upper trailing corner of an enclosing JScrollPane . |
protected void |
unconfigureEnclosingScrollPane()
Unconfigures the enclosing JScrollPane . |
protected void |
updateColumnControlUI()
Updates the ui of the columnControl if appropriate. |
protected void |
updateColumnUI(TableColumn column)
Updates TableColumn after updateUI changes. |
protected void |
updateHighlighterUI()
Updates highlighter after updateUI changes. |
protected void |
updateHorizontalAction()
Synchs selected state of horizontal scrolling Action to
enablement of enhanced auto-resize behaviour. |
protected void |
updateLocaleActionState(String key,
Locale locale)
Updates locale-dependent state of action registered with key in ActionMap . |
protected void |
updateLocaleState(Locale locale)
Updates locale-dependent state to the given Locale . |
protected void |
updateRowHeightUI(boolean respectRowSetFlag)
Auto-adjusts rowHeight to something more pleasing then the default. |
void |
updateUI()
Additionally updates auto-adjusted row height and highlighters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.swing.event.TableColumnModelListener |
---|
columnMoved, columnRemoved |
Field Detail |
---|
public static final String FOCUS_PREVIOUS_COMPONENT
public static final String FOCUS_NEXT_COMPONENT
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 CompoundHighlighter compoundHighlighter
public static final String USE_DTCR_COLORMEMORY_HACK
resetDefaultTableCellRendererHighlighter
,
Constant Field Valuesprotected Highlighter resetDefaultTableCellRendererHighlighter
protected ComponentAdapter dataAdapter
protected boolean isXTableRowHeightSet
adminSetRowHeight(int)
,
setRowHeight(int)
protected Searchable searchable
protected transient org.jdesktop.swingx.JXTable.CellEditorRemover editorRemover
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 column model to use.sm
- The list selection model to use.public JXTable(int numRows, int numColumns)
numRows
- Count of rows to accommodate.numColumns
- Count of columns to accommodate.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)
This can be enabled to show "live" rollover behaviour, f.i. the cursor over a cell rendered by a JXHyperlink.
The default value is true.
rolloverEnabled
- a boolean indicating whether or not the rollover
functionality should be enabled.isRolloverEnabled()
,
getLinkController()
,
createRolloverProducer()
,
RolloverRenderer
public boolean isRolloverEnabled()
setRolloverEnabled(boolean)
protected TableRolloverController<JXTable> getLinkController()
PENDING JW: rename to getRolloverController
setRolloverEnabled(boolean)
,
createLinkController()
,
RolloverController
protected TableRolloverController<JXTable> createLinkController()
getLinkController()
,
RolloverController
protected RolloverProducer createRolloverProducer()
RolloverProducer
to use with this componentsetRolloverEnabled(boolean)
public 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
,
ColumnControlIcon
public 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 Component
o
- 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 JTable
configureColumnControl()
protected void unconfigureEnclosingScrollPane()
JScrollPane
.
Overridden to addionally unconfigure the upper trailing corner with the column control.
unconfigureEnclosingScrollPane
in class JTable
unconfigureColumnControl()
protected void unconfigureColumnControl()
JScrollPane
.
Here: removes the upper trailing corner and resets.
setColumnControlVisible(boolean)
,
setColumnControl(JComponent)
protected void configureColumnControl()
JScrollPane
.
Adds the ColumnControl
if the
columnControlVisible
property is true.
setColumnControlVisible(boolean)
,
setColumnControl(JComponent)
protected String getUIString(String key)
UIPREFIX
before doing the
lookup. The lookup respects this table's current locale
property. Returns the key, if no value is found.
key
- the bare key to look up in the UIManager.
protected String getUIString(String key, Locale locale)
UIPREFIX
before doing the lookup. Returns the key, if no value is found.
key
- the bare key to look up in the UIManager.locale
- the locale use for lookup
public void setLocale(Locale locale)
Overridden to update locale-dependent properties.
setLocale
in class Component
updateLocaleState(Locale)
protected void updateLocaleState(Locale locale)
Locale
.
Here: updates registered column actions' locale-dependent state.
PENDING: Try better to find all column actions including custom additions? Or move to columnControl?
locale
- the Locale to use for value lookupsetLocale(Locale)
,
updateLocaleActionState(String, Locale)
protected void updateLocaleActionState(String key, Locale locale)
ActionMap
. Does nothing if no action with key is found.
Here: updates the Action
's name property.
key
- the string for lookup in this table's ActionMapupdateLocaleState(Locale)
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)
Overridden to update the enabled state of the pack selected column
Action
.
columnSelectionChanged
in interface TableColumnModelListener
columnSelectionChanged
in class JTable
public void setHorizontalScrollEnabled(boolean enabled)
JViewport
horizontally and shows the horizontal scrollbar if necessary.
The default value is false
.
Note: this is not a bound property, though it follows bean naming conventions. PENDING: Probably should be... If so, could be taken by a listening Action as in the app-framework.
PENDING JW: the name is mis-leading?
enabled
- a boolean indicating whether enhanced auto-resize mode is
enabled.isHorizontalScrollEnabled()
public 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 JTable
setHorizontalScrollEnabled(boolean)
protected void updateHorizontalAction()
Action
to
enablement of enhanced auto-resize behaviour.
public boolean getScrollableTracksViewportWidth()
Overridden to support enhanced auto-resize behaviour enabled and necessary.
getScrollableTracksViewportWidth
in interface Scrollable
getScrollableTracksViewportWidth
in class JTable
setHorizontalScrollEnabled(boolean)
public void doLayout()
autoResizeMode
property.
Overridden to support enhanced auto-resize behaviour enabled and necessary.
doLayout
in class JTable
setAutoResizeMode(int)
,
setHorizontalScrollEnabled(boolean)
public void columnMarginChanged(ChangeEvent e)
Overridden to support enhanced auto-resize behaviour enabled and necessary.
columnMarginChanged
in interface TableColumnModelListener
columnMarginChanged
in class JTable
setHorizontalScrollEnabled(boolean)
public void setFillsViewportHeight(boolean fillsViewportHeight)
Overridden for documentation reasons only: same behaviour but different default value.
The default value is true
.
setFillsViewportHeight
in class JTable
public void setValueAt(Object aValue, int row, int column)
!isCellEditable(row, column)
.
setValueAt
in class JTable
isCellEditable(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 JTable
row
- the row index in view coordinatescolumn
- the column index in view coordinates
setValueAt(Object, int, int)
,
isEditable()
,
TableColumnExt.isEditable()
,
TableModel.isCellEditable(int, int)
public boolean getAutoCreateColumnsFromModel()
Overridden for documentation clarification. The property has the same meaning as super, that is if true to re-create all table columns on either setting a new TableModel or receiving a structureChanged from the existing. The most obvious visual effect is that custom column properties appear to be "lost".
JXTable does support additonal custom configuration (via a custom ColumnFactory) which can (and incorrectly was) called independently from the creation. Setting this property to false guarantees that no column configuration is applied.
getAutoCreateColumnsFromModel
in class JTable
tableChanged(TableModelEvent)
,
ColumnFactory
public void tableChanged(TableModelEvent e)
Overridden to re-calculate intialize column width and preferred scrollable size after a structureChanged if autocreateColumnsFromModel is true.
tableChanged
in interface TableModelListener
tableChanged
in class JTable
public void setModel(TableModel dataModel)
Overridden to prevent super from creating RowSorter.
setModel
in class JTable
public void setColumnModel(TableColumnModel columnModel)
Overridden to synch sorter state from columns.
setColumnModel
in class JTable
public void setAutoCreateRowSorter(boolean autoCreateRowSorter)
Overridden to
setAutoCreateRowSorter
in class JTable
public boolean getAutoCreateRowSorter()
Overridden to return xflag
getAutoCreateRowSorter
in class JTable
public void setRowSorter(RowSorter<? extends TableModel> sorter)
Overridden propagate sort-related properties to the sorter after calling super, if the given RowSorter is of type SortController. Does nothing additional otherwise.
setRowSorter
in class JTable
protected void configureSorterProperties()
protected RowSorter<? extends TableModel> createDefaultRowSorter()
PENDING JW: review method signature - better expose the need for the model by adding a parameter?
protected 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.
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
. Note: as of post-1.0 this property is propagated to the SortController. Whether or not a change triggers a re-sort is up to either the concrete controller implementation (the default doesn't) or client code. This behaviour is different from old SwingX style sorting.
sortable
- boolean indicating whether or not this table supports
sortable columnsTableColumnExt.isSortable()
public boolean isSortable()
Note: as of post-1.0 this property is propagated to the SortController.
public void setSortsOnUpdates(boolean sortsOnUpdates)
rowsUpdated
is invoked). For
example, if this is true and the user edits an entry the
location of that item in the view may change. The default is
true.
sortsOnUpdates
- whether or not to sort on update eventspublic boolean getSortsOnUpdates()
public void resetSortOrder()
PENDING JW: method name - consistent in SortController and here.
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.
PRE: 0 <= columnIndex < getColumnCount()
columnIndex
- the columnIndex 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.public SortOrder getSortOrder(int columnIndex)
columnIndex
- the column index in view coordinates.
public void toggleSortOrder(Object identifier)
The exact behaviour of a toggle is defined by the SortController's toggleSortOrder implementation. Typically a unsorted column is sorted in ascending order, a sorted column's order is reversed.
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)
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 returns SortOrder.UNSORTED.
identifier
- the column's identifier.
protected boolean isSortable(int columnIndex)
Here: delegates to the SortController, if available. If not, returns true if both this table and the column sortable property is enabled, false otherwise.
Note: as of post-1.0 this method is no longer used internally, as the responsibility to respect per-column/per-table sortability is moved to the SortController.
columnIndex
- column in view coordinates
protected boolean isSortable(Object identifier)
Here: delegates to the SortController, if available. If not, returns true if both this table and the column sortable property is enabled, false otherwise.
Note: as of post-1.0 this method is no longer used internally, as the responsibility to respect per-column/per-table sortability is moved to the SortController.
identifier
- the column's identifier
protected SortController getSortController()
SortController
may be nullpublic TableColumn getSortedColumn()
public void columnAdded(TableColumnModelEvent e)
Overridden to propagate sort-related column properties to the SortController.
PENDING JW: check correct update on visibility change!
columnAdded
in interface TableColumnModelListener
columnAdded
in class JTable
public 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 TableColumn
s.
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 TableColumn
s.
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 columnPropertyChange(PropertyChangeEvent event)
TableColumn
.
Listens to column property changes.
columnPropertyChange
in interface TableColumnModelExtListener
event
- a PropertyChangeEvent
fired by a TableColumn
contained in a TableColumnModel
public final void createDefaultColumnsFromModel()
TableColumn
s for
columns in this table's TableModel
. Removes all currently
contained TableColumn
s. The exact type and configuration of
the columns is controlled completely by the ColumnFactory
.
Client code can use setColumnFactory(ColumnFactory)
to plug-in a
custom ColumnFactory implementing their own default column creation and
behaviour.
Note: this method will probably become final (Issue #961-SwingX) so it's strongly recommended to not override now (and replace existing overrides by a custom ColumnFactory)!
createDefaultColumnsFromModel
in class JTable
setColumnFactory(ColumnFactory)
,
ColumnFactory
public ColumnFactory getColumnFactory()
setColumnFactory(ColumnFactory)
,
ColumnFactory
public void setColumnFactory(ColumnFactory columnFactory)
ColumnFactory
to use for column creation and
configuration. The default value is the shared application ColumnFactory.
Note: this method has no side-effect, that is existing columns are not re-created automatically, client code must trigger it manually.
columnFactory
- the factory to use, null
indicates to
use the shared application factory.getColumnFactory()
,
ColumnFactory
public 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
.
JScrollPane
setVisibleRowCount(int)
public void setVisibleRowCount(int visibleRowCount)
JScrollPane
.
This is a bound property. The default value is 20.
PENDING: allow negative for use-all? Analogous to visColumnCount.
visibleRowCount
- number of rows to show in a
JScrollPane
IllegalArgumentException
- if given count is negative.getVisibleRowCount()
public int getVisibleColumnCount()
JScrollPane
.
setVisibleColumnCount(int)
public void setVisibleColumnCount(int visibleColumnCount)
JScrollPane
. A negative number is interpreted as use-all
available visible columns.
This is a bound property. The default value is -1 (effectively the same as before the introduction of this property).
visibleColumnCount
- number of rows to show in a
JScrollPane
getVisibleColumnCount()
public void setPreferredScrollableViewportSize(Dimension size)
If the given dimension is null, the auto-calculation of the pref scrollable size is enabled, otherwise the behaviour is the same as super. The default is auto-calc enabled on.
setPreferredScrollableViewportSize
in class JTable
getPreferredScrollableViewportSize()
public Dimension getPreferredScrollableViewportSize()
Overridden to support auto-calculation of pref scrollable size, dependent on the visible row/column count properties. The auto-calc is on if there's no explicit pref scrollable size set. Otherwise the fixed size is returned
The calculation of the preferred scrollable width is delegated to the ColumnFactory to allow configuration with custom strategies implemented in custom factories.
getPreferredScrollableViewportSize
in interface Scrollable
getPreferredScrollableViewportSize
in class JTable
setPreferredScrollableViewportSize(Dimension)
,
ColumnFactory.getPreferredScrollableViewportWidth(JXTable)
protected void initializeColumnWidths()
initializeColumnPreferredWidth(TableColumn)
protected void initializeColumnPreferredWidth(TableColumn column)
ColumnFactory
if the
column is of type TableColumnExt
. Otherwise nothing is
changed.
TODO JW - need to cleanup getScrollablePreferred (refactor and inline)
column
- TableColumn object representing view columnColumnFactory.configureColumnWidths(org.jdesktop.swingx.JXTable, org.jdesktop.swingx.table.TableColumnExt)
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()
protected void doFind()
public Searchable getSearchable()
setSearchable(Searchable)
,
TableSearchable
public void setSearchable(Searchable searchable)
searchable
- the Searchable to use for this table, may be null to indicate
using the table's default 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 void setHighlighters(Highlighter... highlighters)
Highlighter
s to the table, replacing any old
settings. None of the given Highlighters must be null.
This is a bound property.
Note: as of version #1.257 the null constraint is enforced strictly. To remove all highlighters use this method without param.
highlighters
- zero or more not null highlighters to use for
renderer decoration.
NullPointerException
- if array is null or array contains null
values.getHighlighters()
,
addHighlighter(Highlighter)
,
removeHighlighter(Highlighter)
public Highlighter[] getHighlighters()
Highlighter
s used by this table. Maybe empty,
but guarantees to be never null.
setHighlighters(Highlighter[])
public void addHighlighter(Highlighter highlighter)
Highlighter
to the end of the list of used
Highlighter
s. The argument must not be null.
highlighter
- the Highlighter
to add, must not be null.
NullPointerException
- if Highlighter
is null.removeHighlighter(Highlighter)
,
setHighlighters(Highlighter[])
public void removeHighlighter(Highlighter highlighter)
Does nothing if the Highlighter is not contained.
highlighter
- the Highlighter to remove.addHighlighter(Highlighter)
,
setHighlighters(Highlighter...)
protected CompoundHighlighter getCompoundHighlighter()
protected ChangeListener getHighlighterChangeListener()
ChangeListener
to use with highlighters. Lazily
creates the listener.
not-null
protected ChangeListener createHighlighterChangeListener()
Here: repaints the table on receiving a stateChanged.
public String getStringAt(int row, int column)
row
- the row index of the cell in view coordinatescolumn
- the column index of the cell in view coordinates.
public TableCellRenderer getCellRenderer(int row, int column)
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 JTable
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).
Per-column highlighters contained in
TableColumnExt.getHighlighters()
are applied to the renderer
after the table highlighters.
TODO kgs: interaction of search highlighter and column highlighters
Note: DefaultTableCellRenderer and subclasses require a hack to play
nicely with Highlighters because it has an internal "color memory" in
setForeground/setBackground. The hack is applied in
resetDefaultTableCellRendererColors
which is called after
super.prepareRenderer and before applying the Highlighters. The method is
called always and for all renderers.
prepareRenderer
in class JTable
renderer
- 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 cellresetDefaultTableCellRendererColors(Component, int, int)
,
Highlighter
protected void resetDefaultTableCellRendererColors(Component renderer, int row, int column)
USE_DTCR_COLORMEMORY_HACK
having the value of
Boolean.TRUE
, does nothing otherwise. The property is true
by default.
The hack consists of applying a specialized Highlighter
to
force reset the color "memory" of DefaultTableCellRenderer
.
Note that the hack is applied always, that is even if there are no custom
Highlighters.
Client code which solves the problem at the core (that is in a
well-behaved DefaultTableCellRenderer
) can disable the hack
by removing the client property or by subclassing and override this to do
nothing.
renderer
- the TableCellRenderer
to hackrow
- the row of the cell to rendercolumn
- the column index of the cell to renderprepareRenderer(TableCellRenderer, int, int)
,
USE_DTCR_COLORMEMORY_HACK
,
ResetDTCRColorHighlighter
public Component prepareEditor(TableCellEditor editor, int row, int column)
Overridden to adjust the editor's component orientation.
prepareEditor
in class JTable
protected 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.
NOTE: this doesn't work with swingx renderers! Do we really need it? It had been used in JNTable which is practically obsolete. If needed, we could make all renderer support classes clonable.
columnClass
- Class of value being rendered
JTable.getDefaultRenderer(Class)
protected void createDefaultRenderers()
Object
s,
Number
s, Date
s, Boolean
s, and
Icon/Image/
s.
Overridden to install SwingX renderers plus hacking around huge memory consumption of UIDefaults (see #6345050 in core Bug parade)
createDefaultRenderers
in class JTable
DefaultTableRenderer
,
ComponentProvider
protected void createDefaultEditors()
Overridden to hook enhanced editors (f.i. NumberEditorExt
)plus hacking around huge memory consumption of UIDefaults (see #6345050
in core Bug parade)
createDefaultEditors
in class JTable
DefaultCellEditor
public 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 boolean editCellAt(int row, int column, EventObject e)
overridden to install a custom editor remover.
editCellAt
in class JTable
public void removeEditor()
removeEditor
in class JTable
public void removeNotify()
Overridden to uninstall the custom editor remover.
removeNotify
in class JTable
public boolean isFocusCycleRoot()
Overridden to prevent spurious focus loss to outside of table while removing the editor. This is essentially a hack around core bug #6210779. PENDING: add link to wiki!
isFocusCycleRoot
in class Container
public void transferFocus()
Overridden to try to stop the edit, if appropriate. Calls super if succeeded, does not yield otherwise.
transferFocus
in class Component
public void transferFocusBackward()
Overridden to try to stop the edit, if appropiate. Calls super if succeeded, does not yield otherwise.
transferFocusBackward
in class Container
public void updateUI()
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 JTable
protected void updateColumnControlUI()
protected void updateColumnUI(TableColumn column)
column
- the tableColumn to update.protected void updateHighlighterUI()
updateUI
changes.
UIDependent
protected 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 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 setShowGrid(boolean showGrid)
Behaves exactly like super.
It's overridden to warn against a frequent programming error: this method toggles only the visibility of the grid lines, it does not update the row/column margins - which may lead to visual artefacts, as f.i. not showing the lines at all or showing normal table background in selected state where the lines should have been.
setShowGrid
in class JTable
setShowGrid(boolean, boolean)
public void setRowHeight(int rowHeight)
Overriden to mark the request as client-code induced.
setRowHeight
in class JTable
isXTableRowHeightSet
@Deprecated public void setRowHeightEnabled(boolean enabled)
The default value is false
.
enabled
- a boolean to indicate whether per-row heights should be
enabled.isRowHeightEnabled()
,
JTable.setRowHeight(int, int)
@Deprecated public boolean isRowHeightEnabled()
setRowHeightEnabled(boolean)
protected 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)
,
isXTableRowHeightSet
public int rowAtPoint(Point point)
Overridden to work around core Bug (ID #6291631): negative y is mapped to row 0).
rowAtPoint
in class JTable
protected JTableHeader createDefaultTableHeader()
Overridden to return a JXTableHeader
.
createDefaultTableHeader
in class JTable
JXTableHeader
protected TableColumnModel createDefaultColumnModel()
Overridden to return a DefaultTableColumnModelExt
.
createDefaultColumnModel
in class JTable
DefaultTableColumnModelExt
public void setSelectionBackground(Color selectionBackground)
Overridden because super throws NPE on null param.
setSelectionBackground
in class JTable
public void setSelectionForeground(Color selectionForeground)
Overridden because super throws NPE on null param.
setSelectionForeground
in class JTable
public void setGridColor(Color gridColor)
Overridden because super throws NPE on null param.
setGridColor
in class JTable
|
swingx Version 2009-07-31 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |