public interface ITable
JTable
with advanced rendering and editing capabilities and built-in user event handling for links.
Also creates and sets an improved table cell renderer with the unified rendering logic incorporated (
IGuiUtils.renderToLabel(javax.swing.JLabel, Object, boolean, boolean)
).
Additionally if a cell value is a JComponent
, it will be returned as the renderer component.
Overrides tool tip creation and placement to return cell value as tool tip if it's truncated (due to not fitting into its cell's area). Positions tool tips
exactly over the cell they belong to, also avoids showing empty tool tips (by returning null
).
ITable
s are added to Container
s (usually to the center of a IBorderPanel
) by adding the table wrapper component returned by
createWrapperBox(boolean)
or createWrapperBox(boolean, ITToolBarParams)
.
Example table with table tool bar having search and filter support:
IBorderPanel p = guiFactory.newBorderPanel(); ITable table = guiFactory.newTable(); // Add data to table model p.addCenter( table.createWrapperBox( true, table.createToolBarParams( p ) ) );
ITableModel
,
ITableRowSorter
,
IToolBarForTable
,
IProgressBarView
,
IBarCodeView
,
IGuiFactory.newTable()
Modifier and Type | Method and Description |
---|---|
javax.swing.JTable |
asTable()
Casts this instance to
JTable . |
ITToolBarParams |
createToolBarParams(javax.swing.JComponent rootComponent)
Creates and returns a new table tool bar parameters wrapper.
|
javax.swing.JComponent |
createWrapperBox(boolean wrapInScrollPane)
Creates and returns a vertical
Box holding the table header and the table itself optionally wrapped in a IScrollPane , with no table tool
bar. |
javax.swing.JComponent |
createWrapperBox(boolean wrapInScrollPane,
ITToolBarParams toolBarParams)
Creates and returns a vertical
Box holding the table header and the table itself optionally wrapped in a IScrollPane . |
javax.swing.table.TableCellRenderer |
getCellRenderer(int row,
int column)
Overrides
JTable.getCellRenderer(int, int) to returns the table cell renderer explicitly set by setTableCellRenderer(TableCellRenderer) ,
or else the internal improved table cell renderer. |
int |
getFocusedRow()
Returns the VIEW index of the focused row, -1 if no row is focused.
|
int |
getSelectedModelRow()
Returns the first selected row MODEL index.
|
int[] |
getSelectedModelRows()
Returns the selected row MODEL indices.
|
javax.swing.table.TableCellRenderer |
getTableCellRenderer()
Returns the table cell renderer which is returned by
JTable.getCellRenderer(int, int) . |
javax.swing.table.TableCellRenderer |
getXTableCellRenderer()
Returns the internal, improved table cell renderer of this improved table.
|
ITableModel |
getXTableModel()
Returns the improved table model of this improved table.
|
ITableRowSorter |
getXTableRowSorter()
Returns the improved table row sorter of this improved table.
|
boolean |
isEditable()
Tells if the table is editable.
|
void |
pack()
Packs the table.
Resizes all columns (by setting the PREFERRED width of the column) to the maximum width of the values in each column. |
void |
packColumns(int... columns)
Packs the specified columns.
Resizes the specified column (by setting the PREFERRED and MAXIMUM width of the columns) to the maximum width of the values in the column. |
void |
packColumnsExceptLast()
Packs all columns except the last (last by view idx).
Resizes all columns except the last (by setting the PREFERRED and MAXIMUM width of the columns) to the maximum width of the values in the column. |
void |
restoreSelection(int idColIdx)
Restores the selection that was saved by
saveSelection(int) . |
void |
saveSelection(int idColIdx)
Saves the current selection for later restoring by
restoreSelection(int) . |
void |
setCtrlOpenAction(IAction ctrlOpenAction)
Sets the ctrl-open action to be called when the user presses the CTRL+ENTER keys.
|
void |
setDeleteAction(IAction deleteAction)
Sets the delete action to be called when the user presses the DEL key.
|
void |
setEditable(boolean editable)
Sets if the table is editable.
|
void |
setEditableColModelIndices(int... editableColModelIndices)
Sets the editable column model indices.
|
void |
setOpenAction(IAction openAction)
Sets the open action to be called when the user double clicks or presses the ENTER key.
|
void |
setRowHeightForProgressBar()
Sets a bigger minimum row height which is suitable to display progress bar cells.
|
void |
setShiftOpenAction(IAction shiftOpenAction)
Sets the shift-open action to be called when the user presses the SHIFT+ENTER keys.
|
void |
setSortable(boolean sortable)
Enables or disables table sorting.
|
void |
setTableCellRenderer(javax.swing.table.TableCellRenderer tableCellRenderer)
Sets the table cell renderer to be returned by
JTable.getCellRenderer(int, int) . |
javax.swing.JTable asTable()
JTable
.this
as a JTable
int getFocusedRow()
javax.swing.JComponent createWrapperBox(boolean wrapInScrollPane)
Box
holding the table header and the table itself optionally wrapped in a IScrollPane
, with no table tool
bar.wrapInScrollPane
- tells if the table has to be added wrapped in a IScrollPane
Box
holding the table header and the table "body"createToolBarParams(JComponent)
javax.swing.JComponent createWrapperBox(boolean wrapInScrollPane, ITToolBarParams toolBarParams)
Box
holding the table header and the table itself optionally wrapped in a IScrollPane
.wrapInScrollPane
- tells if the table has to be added wrapped in a IScrollPane
toolBarParams
- optional table tool bar parameters wrapper; if missing, the created wrapper box will not have a table tool barBox
holding the table header and the table "body"createToolBarParams(JComponent)
ITToolBarParams createToolBarParams(javax.swing.JComponent rootComponent)
rootComponent
- root component to register key strokes atcreateWrapperBox(boolean, ITToolBarParams)
javax.swing.table.TableCellRenderer getXTableCellRenderer()
void setTableCellRenderer(javax.swing.table.TableCellRenderer tableCellRenderer)
JTable.getCellRenderer(int, int)
.tableCellRenderer
- table cell renderer to be setjavax.swing.table.TableCellRenderer getTableCellRenderer()
JTable.getCellRenderer(int, int)
.JTable.getCellRenderer(int, int)
ITableModel getXTableModel()
ITableRowSorter getXTableRowSorter()
void setEditable(boolean editable)
editable
- tells whether table is editableisEditable()
,
setEditableColModelIndices(int...)
boolean isEditable()
setEditable(boolean)
void setEditableColModelIndices(int... editableColModelIndices)
editableColModelIndices
- editable column model indices to be setjavax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
JTable.getCellRenderer(int, int)
to returns the table cell renderer explicitly set by setTableCellRenderer(TableCellRenderer)
,
or else the internal improved table cell renderer.row
- row of the cell whose renderer to returncolumn
- column of the cell whose renderer to returnsetTableCellRenderer(TableCellRenderer)
, or else the internal improved table cell renderervoid pack()
packColumns(int...)
,
packColumnsExceptLast()
void packColumns(int... columns)
columns
- column view indices to be packedpack()
,
packColumnsExceptLast()
void packColumnsExceptLast()
pack()
,
packColumns(int...)
int[] getSelectedModelRows()
int getSelectedModelRow()
void setSortable(boolean sortable)
Iterates over all current columns, and sets their sortable property at the row sorter.
Does not remove the row sorter because it is needed for the table tool bar.
sortable
- tells if table is sortablevoid setOpenAction(IAction openAction)
openAction
- open action to be setsetCtrlOpenAction(IAction)
,
setShiftOpenAction(IAction)
void setCtrlOpenAction(IAction ctrlOpenAction)
ctrlOpenAction
- ctrl-open action to be setsetOpenAction(IAction)
,
setShiftOpenAction(IAction)
void setShiftOpenAction(IAction shiftOpenAction)
shiftOpenAction
- shift-open action to be setsetOpenAction(IAction)
,
setCtrlOpenAction(IAction)
void setDeleteAction(IAction deleteAction)
deleteAction
- delete action to be setvoid saveSelection(int idColIdx)
restoreSelection(int)
.
Implementation details:
Saving the selection is done by saving the object at the model column idColIdx
of each selected row in a Set
.
Upon restoring the selection, the object at the model column idColIdx
of each row is checked if contained in the saved selection, and if so,
the row will be selected. This solution is based on the Object.equals(Object)
method of the id objects of the rows.
idColIdx
- column model index whose value to be used as the row idrestoreSelection(int)
void restoreSelection(int idColIdx)
saveSelection(int)
.
After restoring the selection, the saved selection is cleared / discarded.
For implementation details see saveSelection(int)
.
idColIdx
- column model index whose value to be used as the row id selectionsaveSelection(int)
void setRowHeightForProgressBar()
IProgressBarView
,
IProgressBar
This API documentation is public and is intended for / allowed to be used by anyone.
Scelight home page: https://sites.google.com/site/scelight/
Scelight is a trademark of András Belicza. Copyright © András Belicza, 2013-2015. All rights reserved.