java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
org.jdesktop.swingx.JXTable
public class JXTable
This is a partial copy of JXTable javadoc. The focus is on stand-alone table fields/methods (their details section), that is those which are unreleated to cross-component themes. All summaries and unrelated field/method details are cut.
Field Detail |
---|
public static final String HORIZONTALSCROLL_ACTION_COMMAND
ActionMap
.
public static final String PACKALL_ACTION_COMMAND
ActionMap
.
public static final String PACKSELECTED_ACTION_COMMAND
ActionMap
.
public static final String UIPREFIX
ResourceBundle
.
protected boolean isXTableRowHeightSet
adminSetRowHeight(int)
,
setRowHeight(int)
Constructor Detail |
---|
public JXTable()
public JXTable(TableModel dm)
dm
- The model to use.public JXTable(TableModel dm,
TableColumnModel cm)
dm
- The model to use.public JXTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
dm
- The table model to use.cm
- The colomn model to use.sm
- The list selection model to use.public JXTable(int numRows,
int numColumns)
numRows
- Count of rows to accomodate.numColumns
- Count of columns to accomodate.public JXTable(Vector rowData,
Vector columnNames)
rowData
- Row data, as a Vector of Objects.columnNames
- Column names, as a Vector of Strings.public JXTable(Object[][] rowData,
Object[] columnNames)
rowData
- Row data, as a two-dimensional Array of Objects (by row, for column).columnNames
- Column names, as a Array of Strings.Method Detail |
---|
public void packAll()
By
default this method is bound to the pack all columns Action
and registered in the table's ActionMap
.
public void packSelected()
By
default this method is bound to the pack selected column Action
and registered in the table's ActionMap
.
public void columnSelectionChanged(ListSelectionEvent e)
TableColumnModel
is changed. Application code will not use these methods explicitly, they are used internally by JTable.
Overridden to update the enabled state of the pack selected column Action
.
columnSelectionChanged
in interface TableColumnModelListener
columnSelectionChanged
in class JTable
e
- the event receivedTableColumnModelListener
public void setHorizontalScrollEnabled(boolean enabled)
JViewport
horizontally and shows the horizontal scrollbar if necessary.
The default value is false
.
PENDING JW: the name is mis-leading?
enabled
- a boolean indicating whether enhanced auto-resize mode is enabled.isHorizontalScrollEnabled()
protected boolean isHorizontalScrollEnabled()
setHorizontalScrollEnabled(boolean)
public void setAutoResizeMode(int mode)
Overridden for internal bookkeeping related to the enhanced auto-resize behaviour.
Note: to enable/disable the enhanced
auto-resize mode use exclusively setHorizontalScrollEnabled
,
this method can't cope with it.
setAutoResizeMode
in class JTable
mode
- One of 5 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN,
AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN,
AUTO_RESIZE_ALL_COLUMNSsetHorizontalScrollEnabled(boolean)
protected void updateHorizontalAction()
Action
to enablement of enhanced auto-resize behaviour.
public boolean getScrollableTracksViewportWidth()
autoResizeMode
is
set to AUTO_RESIZE_OFF
, which indicates that
the width of the viewport does not determine the width of the table.
Otherwise returns true. Overridden to support enhanced auto-resize behaviour enabled and necessary.
getScrollableTracksViewportWidth
in interface Scrollable
getScrollableTracksViewportWidth
in class JTable
autoResizeMode
is set to AUTO_RESIZE_OFF
, otherwise returns
truesetHorizontalScrollEnabled(boolean)
public void doLayout()
JTable
's
columns is equal to the width of the table.Overridden to support enhanced auto-resize behaviour enabled and necessary.
doLayout
in class JTable
setHorizontalScrollEnabled(boolean)
public void columnMarginChanged(ChangeEvent e)
Application code will not use these methods explicitly, they are used internally by JTable.
Overridden to support enhanced auto-resize behaviour enabled and necessary.
columnMarginChanged
in interface TableColumnModelListener
columnMarginChanged
in class JTable
e
- the event receivedsetHorizontalScrollEnabled(boolean)
public void setFillsViewportHeight(boolean fillsViewportHeight)
The
default value is true
.
Note: this a backport from Mustang's JTable
.
fillsViewportHeight
- boolean to indicate whether the table should always fill parent's
height.getFillsViewportHeight()
,
getScrollableTracksViewportHeight()
public boolean getFillsViewportHeight()
setFillsViewportHeight(boolean)
,
getScrollableTracksViewportHeight()
public boolean getScrollableTracksViewportHeight()
Overridden to control the tracksHeight property depending on fillsViewportHeight and relative size to containing parent.
getScrollableTracksViewportHeight
in interface Scrollable
getScrollableTracksViewportHeight
in class JTable
setFillsViewportHeight(boolean)
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 int getVisibleRowCount()
JScrollPane
.
JScrollPane
setVisibleRowCount(int)
public void setVisibleRowCount(int visibleRowCount)
JScrollPane
.
TODO JW - make bound property, reset scrollablePref(? distinguish internal from client code triggered like in rowheight?) and re-layout.
visibleRowCount
- number of rows to show in a JScrollPane
getVisibleRowCount()
public Dimension getPreferredScrollableViewportSize()
TODO JW: refactor and comment.
getPreferredScrollableViewportSize
in interface Scrollable
getPreferredScrollableViewportSize
in class JTable
Dimension
object containing the preferredSize
of the JViewport
which displays this tableScrollable.getPreferredScrollableViewportSize()
protected void initializeColumnPreferredWidth(TableColumn column)
TableColumnExt
or prototypeValue
is null
then the preferredWidth is left
unmodified. TODO JW - need to cleanup getScrollablePreferred (refactor and inline) update doc - what exactly happens is left to the columnfactory.
column
- TableColumn object representing view columnTableColumnExt.setPrototypeValue(java.lang.Object)
public void scrollRowToVisible(int row)
JViewport
.
Note: this method has no precondition as it internally uses getCellRect
which is lenient to off-range coordinates.
row
- the view row index of the cellscrollColumnToVisible(int)
,
scrollCellToVisible(int,
int)
, JComponent.scrollRectToVisible(Rectangle)
public void scrollColumnToVisible(int column)
JViewport
.
Note: this method has no precondition as it internally uses getCellRect
which is lenient to off-range coordinates.
column
- the view column index of the cellscrollRowToVisible(int)
,
scrollCellToVisible(int,
int)
, JComponent.scrollRectToVisible(Rectangle)
public void scrollCellToVisible(int row,
int column)
JViewport
.
Note: this method has no precondition as it internally uses getCellRect
which is lenient to off-range coordinates.
row
- the view row index of the cellcolumn
- the view column index of the cellscrollColumnToVisible(int)
,
scrollRowToVisible(int)
,
JComponent.scrollRectToVisible(Rectangle)
public int getSelectionMode()
PENDING JW - setter?
ListSelectionModel.getSelectionMode()
public TableCellRenderer getCellRenderer(int row,
int column)
TableColumn
for
this column has a non-null renderer, returns that. If not, finds the
class of the data in this column (using getColumnClass
)
and returns the default renderer for this type of data. Note: Throughout the table package, the internal implementations always use this method to provide renderers so that this default behavior can be safely overridden by a subclass.
Overridden to fix
core bug #4614616 (NPE if TableModel
's Class
for the column is an interface). This method guarantees to always
return a not null
value. Returns the default
renderer for Object
if super returns null
.
getCellRenderer
in class JTable
row
- the row of the cell to render, where 0 is the first rowcolumn
- the column of the cell to render, where 0 is the first column
null
returns the
default renderer for this type of objectDefaultTableCellRenderer
,
TableColumn.setCellRenderer(javax.swing.table.TableCellRenderer)
,
JTable.setDefaultRenderer(java.lang.Class,
javax.swing.table.TableCellRenderer)
public Component prepareEditor(TableCellEditor editor,
int row,
int column)
row
, column
.
Note: Throughout the table package, the internal implementations always use this method to prepare editors so that this default behavior can be safely overridden by a subclass.
Overridden to adjust the editor's component orientation.
prepareEditor
in class JTable
editor
- the TableCellEditor
to set uprow
- the row of the cell to edit, where 0 is the first rowcolumn
- the column of the cell to edit, where 0 is the first column
Component
being editedprotected void adjustComponentOrientation(Component stamp)
Component
's orientation
to this JXTable
's CO if appropriate. The
parameter must not be null
. This implementation synchs the CO always.
stamp
- the Component
who's CO may need to be
synched, must not be null
.public TableCellRenderer getNewDefaultRenderer(Class columnClass)
getDefaultRenderer()
in that it returns a new instance each time so
that the renderer may be set and customized on a particular column.
columnClass
- Class of value being rendered
JTable.getDefaultRenderer(Class)
protected void createDefaultRenderers()
Overridden so we can act as factory for renderers plus hacking around huge memory consumption of UIDefaults (see #6345050 in core Bug parade)
Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons.
createDefaultRenderers
in class JTable
DefaultTableCellRenderer
protected void createDefaultEditors()
Overridden to hook enhanced editors plus hacking around huge memory consumption of UIDefaults (see #6345050 in core Bug parade)
createDefaultEditors
in class JTable
DefaultCellEditor
public boolean isTerminateEditOnFocusLost()
setTerminateEditOnFocusLost(boolean)
public void setTerminateEditOnFocusLost(boolean terminate)
JTable.CellEditorRemover
:
"outside" is interpreted to be on a component which is not under the
table hierarchy but inside the same toplevel window, "terminate" does
so in any case, first tries to stop the edit, if that's unsuccessful it
cancels the edit. The default value is true
.
terminate
- the flag to determine whether or not to terminate the editisTerminateEditOnFocusLost()
public boolean isAutoStartEditOnKeyStroke()
setAutoStartEditOnKeyStroke(boolean)
public void setAutoStartEditOnKeyStroke(boolean autoStart)
The default value is true
.
autoStart
- boolean to determine whether a keyStroke should try to start editing.isAutoStartEditOnKeyStroke()
public void updateUI()
UIManager
that the L&F has changed. Replaces the current UI object with
the latest version from the UIManager
. Additionally updates auto-adjusted row height and highlighters.
Another of the override motivation is to fix core issue (?? ID): super fails to update all renderers/editors.
updateUI
in class JTable
JComponent.updateUI()
protected void updateHighlighterUI()
updateUI
changes.
Highlighter.UIHighlighter
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 setDefaultMargins(boolean showHorizontalLines,
boolean showVerticalLines)
showHorizontalLines
- boolean to decide whether to draw horizontal grid lines.showVerticalLines
- boolean to decide whether to draw vertical grid lines.public void setShowGrid(boolean showHorizontalLines,
boolean showVerticalLines)
showHorizontalLines
- boolean to decide whether to draw horizontal grid lines.showVerticalLines
- boolean to decide whether to draw vertical grid lines.JTable.setShowGrid(boolean)
,
JTable.setIntercellSpacing(Dimension)
public void setRowHeight(int rowHeight)
rowHeight
,
revalidates, and repaints. The height of the cells will be equal to the
row height minus the row margin. Overriden to keep view/model coordinates of SizeSequence in synch. Marks the request as client-code induced.
setRowHeight
in class JTable
rowHeight
- new row heightisXTableRowHeightSet
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)
point
lies in, or -1 if the result is not in the range [0, getRowCount()
-1].
Overridden to work around core Bug (ID #6291631): negative y is mapped to row 0).
rowAtPoint
in class JTable
point
- the location of interest
point
lies in, or -1 if
the result is not in the range [0, getRowCount()
-1]JTable.columnAtPoint(java.awt.Point)
protected JTableHeader createDefaultTableHeader()
JTableHeader
.
A subclass can override this method to return a different table header
object. Overridden to return a JXTableHeader
.
createDefaultTableHeader
in class JTable
JXTableHeader
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |