public interface ExtendedTable<C extends JComponent> extends MasterDetailComponent<C>
ExtendedTable
interface provides a useful extension to the
subclasses of JTable
.MasterDetailComponent.DetailHandler
FormularComponent.ValueChangeListener
Modifier and Type | Field and Description |
---|---|
static String |
EDITABLE_PROPERTY
Property constant for "editable".
|
DATA_FIELD_SEPARATOR
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears any existing data before creating the new
DefaultTableModel . |
void |
ensureCellIsVisible(int rowIndex,
int columnIndex)
Scrolls to the desired cell.
|
void |
ensureColumnIsVisible(int columnIndex)
Scrolls to the desired column.
|
void |
ensureRowIsVisible(int rowIndex)
Scrolls to the desired row.
|
void |
exportCSV(Writer writer)
|
void |
exportCSV(Writer writer,
char delimiter)
|
void |
exportCSV(Writer writer,
char delimiter,
boolean withColumnNames)
|
int |
getColumnAtPoint(int x,
int y)
Returns the index of the column that x- and y-coordinate lies in or -1 if
the result is not in the range [0,
JTable.getColumnCount() -1]. |
int |
getColumnAtPoint(Point location)
This method is a alias for
JTable.columnAtPoint(Point) . |
Color |
getEvenBackground()
Returns the background
Color of even rows. |
Color |
getOddBackground()
Returns the background
Color of odd rows. |
int |
getRowAtPoint(int x,
int y)
Returns the view-index of the row that x- and y-coordinate lies in.
|
int |
getRowAtPoint(Point location)
Returns the view-index of the row that
Point lies in, or -1 if
the result is not in the range [0, JTable.getRowCount() -1]. |
int |
getSelectedModelRow()
Returns the index of the
TableModel for the first selected row or
-1 if no row is selected. |
int[] |
getSelectedModelRows()
Returns the indices of all selected rows in the
TableModel . |
VirtualTable.VirtualTableRow |
getSelectedVirtualTableRow()
Returns the selected
VirtualTable.VirtualTableRow of this component, or
null if nothing is selected. |
VirtualTable.VirtualTableRow[] |
getSelectedVirtualTableRows()
Returns the selected
VirtualTable.VirtualTableRow s of this component, or an
empty array if nothing is selected. |
int |
getVisibleRowCount()
Returns the value of the
visibleRows property. |
boolean |
isEditable()
Determines if the
ExtendedTable is editable. |
boolean |
isSomethingSelected()
Return
true if something is selected, otherwise
false . |
void |
setColumnTitle(int index,
String title)
Sets the title of the desired column with the
index . |
void |
setColumnWidth(int index,
int width)
Sets the columns
preferredWidth and the columns
width . |
void |
setDefaultEditor(TableCellEditor editor)
Clears all previous set editors and registers
editor as
default editor for Object.class , which makes it the default
editor as long as no other editor is set for a specific column class. |
void |
setDefaultRenderer(TableCellRenderer renderer)
Clears all previous set renderers and registers
renderer as
default renderer for Object.class , which makes it the
default renderer as long as no other renderer is set for a specific
column class. |
void |
setEditable(boolean editable)
Sets the specified boolean to indicate whether or not this
ExtendedTable should be editable. |
void |
setEvenBackground(Color evenBackground)
Sets the background
Color of even rows. |
void |
setModel(VirtualTable vt)
Creates a new
TableModel based on a VirtualTable and
other specified parameters and sets it for this Table . |
void |
setModel(VirtualTable vt,
String columns,
boolean queryData)
Creates a new
TableModel based on a VirtualTable and
other specified parameters and sets it for this Table . |
void |
setModel(VirtualTable vt,
String columns,
boolean queryData,
boolean selectiveQuery)
Creates a new
TableModel based on a VirtualTable and
other specified parameters and sets it for this Table . |
void |
setModel(VirtualTable vt,
String columns,
SELECT select,
Object... params)
Creates a new
TableModel based on a VirtualTable and
other specified parameters and sets it for this Table . |
void |
setOddBackground(Color oddBackground)
Sets the background
Color of odd rows. |
void |
setSelectedModelRow(int row)
Selects the row
row in the view. |
void |
setSelectedModelRows(int[] rows)
Selects all rows with the indices specified in the list.
|
void |
setSelectedModelRows(int start,
int end)
Changes the selection to be between
start and
end inclusive. |
void |
setSelectedRows(int[] indices)
Changes the selection to be the set of indices specified by the given
array.
|
void |
setSelectedVirtualTableRow(VirtualTable.VirtualTableRow row)
Selects the row in the table if present.
|
void |
setSelectedVirtualTableRows(VirtualTable.VirtualTableRow[] rows)
Selects the rows in the table if present.
|
void |
setVisibleRowCount(int visibleRows)
Sets the
visibleRows property, which has different meanings
depending on the layout orientation: For a VERTICAL layout
orientation, this sets the preferred number of rows to display without
requiring scrolling; for other orientations, it affects the wrapping of
cells. |
clearModel, refresh, setDetailHandler, setMasterValue
addValidator, addValueChangeListener, getClientProperty, getDataField, getFilterOperator, getFormularName, getFormularValue, getValidators, hasStateChanged, isEnabled, isMultiSelect, isReadOnly, isVisible, putClientProperty, removeValidator, restoreState, saveState, setDataField, setFilterOperator, setFormularValue, setFormularValue, setReadOnly, validateState, validateState, verify
getVirtualTable, setVirtualTable, updateModel
static final String EDITABLE_PROPERTY
boolean isEditable()
ExtendedTable
is editable. Returns
true
if the ExtendedTable
is editable or
false
if not.true
if the ExtendedTable
is editable or
false
if not.void setEditable(boolean editable)
ExtendedTable
should be editable. A PropertyChange event
("EDITABLE_PROPERTY") is fired when the state is changed.editable
- the boolean to be setvoid setModel(VirtualTable vt)
TableModel
based on a VirtualTable
and
other specified parameters and sets it for this Table
.
The TableModel
contains all columns and all rows of the specified
vt
vt
- the VirtualTable
containing the data for the
TableModel
void setModel(VirtualTable vt, String columns, boolean queryData)
TableModel
based on a VirtualTable
and
other specified parameters and sets it for this Table
.vt
- the VirtualTable
containing the data for the
TableModel
columns
- a comma separated list of valid column names for the param
vt
, may be "*" for all columnsqueryData
- if true
, the best fitting select for this vt
is usedvoid setModel(VirtualTable vt, String columns, boolean queryData, boolean selectiveQuery)
TableModel
based on a VirtualTable
and
other specified parameters and sets it for this Table
.vt
- the VirtualTable
containing the data for the
TableModel
columns
- a comma separated list of valid column names for the param
vt
, may be "*" for all columnsqueryData
- if true
, the best fitting select for this vt
is usedselectiveQuery
- if true
, only the display columns
are
queriedvoid setModel(VirtualTable vt, String columns, SELECT select, Object... params)
TableModel
based on a VirtualTable
and
other specified parameters and sets it for this Table
.vt
- the VirtualTable
containing the data for the
TableModel
columns
- a comma separated list of valid column names for the param
vt
, may be "*" for all columnsselect
- a custom SELECT
for filtering or ordering the results
of the vt
, may be null for the default selectparams
- a set of parameters related to the param select
, may
be nullvoid setVisibleRowCount(int visibleRows)
visibleRows
property, which has different meanings
depending on the layout orientation: For a VERTICAL
layout
orientation, this sets the preferred number of rows to display without
requiring scrolling; for other orientations, it affects the wrapping of
cells.visibleRows
- an integer specifying the preferred number of rows to display
without requiring scrollinggetVisibleRowCount()
,
JComponent.getVisibleRect()
,
JViewport
int getVisibleRowCount()
visibleRows
property. See the
documentation for setVisibleRowCount(int)
for details on how to
interpret this value.visibleRows
property.setVisibleRowCount(int)
void setEvenBackground(Color evenBackground)
Color
of even rows.evenBackground
- The background of even rows as type Color
.Color getEvenBackground()
Color
of even rows.Color
.void setOddBackground(Color oddBackground)
Color
of odd rows.oddBackground
- The background of odd rows as type Color
.Color getOddBackground()
Color
of odd rows.Color
.void exportCSV(Writer writer) throws IOException
XdevTable
as CSV information to a specified
Writer
.
This is an alias for exportCSV(Writer, char)
.
writer
- the Writer
to write CSV information toIOException
- if CSV file couldn't be writtenvoid exportCSV(Writer writer, char delimiter) throws IOException
XdevTable
as CSV information to a specified
Writer
.
This is an alias for exportCSV(Writer, char, boolean)
.
writer
- the Writer
to write CSV information todelimiter
- the delimiter to use for separating entries.IOException
- if CSV file couldn't be writtenvoid exportCSV(Writer writer, char delimiter, boolean withColumnNames) throws IOException
writer
- the Writer
to write CSV information todelimiter
- the delimiter to use for separating entries.withColumnNames
- a flag to control whether the columns are writtenIOException
- if CSV file couldn't be writtenvoid clear()
DefaultTableModel
.void setDefaultRenderer(TableCellRenderer renderer)
renderer
as
default renderer for Object.class
, which makes it the
default renderer as long as no other renderer is set for a specific
column class.renderer
- the new default renderersetDefaultEditor(TableCellEditor)
,
TableColumn.setCellRenderer(TableCellRenderer)
void setDefaultEditor(TableCellEditor editor)
editor
as
default editor for Object.class
, which makes it the default
editor as long as no other editor is set for a specific column class.editor
- the new default editorsetDefaultRenderer(TableCellRenderer)
,
TableColumn.setCellEditor(TableCellEditor)
boolean isSomethingSelected()
true
if something is selected, otherwise
false
.true
if something is selected, otherwise
false
int getSelectedModelRow() throws IndexOutOfBoundsException
TableModel
for the first selected row or
-1 if no row is selected.TableModel
IndexOutOfBoundsException
- if sorting is enabled and passed an index outside the range
of the JTable
as determined by the method
JTable.getRowCount()
JTable.convertRowIndexToModel(int)
,
JTable.getSelectedRow()
int[] getSelectedModelRows() throws IndexOutOfBoundsException
TableModel
.IndexOutOfBoundsException
- if sorting is enabled and passed an index outside the range
of the JTable
as determined by the method
JTable.getRowCount()
JTable.convertRowIndexToModel(int)
,
JTable.getSelectedRows()
VirtualTable.VirtualTableRow getSelectedVirtualTableRow()
VirtualTable.VirtualTableRow
of this component, or
null
if nothing is selected.getSelectedVirtualTableRow
in interface MasterDetailComponent<C extends JComponent>
VirtualTable.VirtualTableRow
of this componentvoid setSelectedVirtualTableRow(VirtualTable.VirtualTableRow row)
row
- the row to selectVirtualTable.VirtualTableRow[] getSelectedVirtualTableRows()
VirtualTable.VirtualTableRow
s of this component, or an
empty array if nothing is selected.VirtualTable.VirtualTableRow
s of this componentvoid setSelectedVirtualTableRows(VirtualTable.VirtualTableRow[] rows)
rows
- the rows to selectvoid setSelectedModelRow(int row) throws IndexOutOfBoundsException, IllegalArgumentException
row
in the view. If the row
<
0, all columns and rows are deselected.row
- the index of the row in terms of the modelIndexOutOfBoundsException
- if sorting is enabled and passed an index outside the range
of the JTable
as determined by the method
JTable.getRowCount()
IllegalArgumentException
- if row
lie outside [0,
JTable.getRowCount()
-1]JTable.convertRowIndexToView(int)
,
JTable.addRowSelectionInterval(int, int)
,
JTable.clearSelection()
void setSelectedModelRows(int[] rows) throws IndexOutOfBoundsException, IllegalArgumentException
rows
are null
all columns and rows are
deselected.rows
- an list of integers containing the row indicesIndexOutOfBoundsException
- if sorting is enabled and passed an index outside the range
of the JTable
as determined by the method
JTable.getRowCount()
IllegalArgumentException
- if row
lie outside [0,
JTable.getRowCount()
-1]JTable.convertRowIndexToView(int)
,
JTable.addRowSelectionInterval(int, int)
,
JTable.clearSelection()
,
setSelectedModelRows(int[])
void setSelectedModelRows(int start, int end)
start
and
end
inclusive. start
doesn't have to be less
than or equal to end
.
In SINGLE_SELECTION
selection mode, only the second index is
used.
If this represents a change to the current selection, then each
ListSelectionListener
is notified of the change.
start
- one end of the interval.end
- other end of the intervalvoid setSelectedRows(int[] indices)
addSelectionInterval
on the selection model to add the indices.
Refer to the documentation of the selection model class being used for
details on how values less than 0
are handled.indices
- an array of the indices of the rows to select,
non-null
int getRowAtPoint(int x, int y) throws IndexOutOfBoundsException
x
- the x coordinate of the rowy
- the y coordinate of the rowIndexOutOfBoundsException
- if sorting is enabled and passed an index outside the range
of the JTable
as determined by the method
JTable.getRowCount()
getRowAtPoint(Point)
int getRowAtPoint(Point location) throws IndexOutOfBoundsException
Point
lies in, or -1 if
the result is not in the range [0, JTable.getRowCount()
-1].location
- the Point
of the rowIndexOutOfBoundsException
- if sorting is enabled and passed an index outside the range
of the JTable
as determined by the method
JTable.getRowCount()
getRowAtPoint(int, int)
int getColumnAtPoint(int x, int y)
JTable.getColumnCount()
-1].x
- the x coordinate of the columny
- the y coordinate of the columnJTable.getColumnCount()
-1]getColumnAtPoint(Point)
int getColumnAtPoint(Point location)
JTable.columnAtPoint(Point)
.location
- of interestlocation
lies in or -1
if the result is not in the range [0,
JTable.getColumnCount()
-1]getColumnAtPoint(int, int)
void setColumnWidth(int index, int width)
preferredWidth
and the columns
width
.index
- the index of the desired columnwidth
- the value for the column widthTableColumn.setPreferredWidth(int)
,
TableColumn.setWidth(int)
void setColumnTitle(int index, String title)
index
.index
- the index of the desired columntitle
- the value for the column titleTableColumn.setHeaderValue(Object)
void ensureCellIsVisible(int rowIndex, int columnIndex)
Note: Works only if the table is contained in a
JScrollPane
.
rowIndex
- index of row to scroll tocolumnIndex
- index of the column to scroll tovoid ensureRowIsVisible(int rowIndex)
Note: Works only if the table is contained in a
JScrollPane
.
rowIndex
- index of row to scroll tovoid ensureColumnIsVisible(int columnIndex)
Note: Works only if the table is contained in a
JScrollPane
.
columnIndex
- index of the column to scroll toCopyright © 2003–2021 XDEV Software. All rights reserved.