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 fields/methods (their details section) related to the table's enhanced column support, all summaries and unrelated field/method details have been cut.
Field Detail |
---|
Constructor Detail |
---|
Method Detail |
---|
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 shown#getColumnControlVisible()
, 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 configureColumnControl()
JScrollPane
.
Adds/removes the ColumnControl
depending on the columnControlVisible
property.
setColumnControlVisible(boolean)
, setColumnControl(JComponent)
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 JTable
aValue
- 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 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 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()
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 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 by the ColumnFactory
.
createDefaultColumnsFromModel
in class JTable
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.
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)
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 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)
protected TableColumnModel createDefaultColumnModel()
DefaultTableColumnModel
. A subclass can override this
method to return a different column model object.
Overridden to return a DefaultTableColumnModelExt
.
createDefaultColumnModel
in class JTable
DefaultTableColumnModelExt
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |