Interface IJTable
- All Superinterfaces:
IComponent, IContainer, IJComponent
- All Known Implementing Classes:
JTableImpl
- Author:
- thevpc
-
Method Summary
Modifier and TypeMethodDescriptionintcolumnAtPoint(Point point) Returns the index of the column thatpointlies in, or -1 if the result is not in the range [0,getColumnCount()-1].intconvertColumnIndexToModel(int i) intconvertColumnIndexToView(int i) intconvertRowIndexToModel(int i) intconvertRowIndexToView(int i) getCellRect(int row, int column, boolean includeSpacing) Returns a rectangle for the cell that lies at the intersection ofrowandcolumn.Returns theTableColumnModelthat contains all column information of this table.getModel()intReturns the index of the first selected column, -1 if no column is selected.intReturns the index of the first selected row, -1 if no row is selected.int[]Returns the indices of all selected rows.Returns theListSelectionModelthat is used to maintain row selection state.introwAtPoint(Point point) Returns the index of the row thatpointlies in, or -1 if the result is not in the range [0,getRowCount()-1].voidsetDefaultRenderer(Class<?> columnClass, TableCellRenderer renderer) Sets a default cell renderer to be used if no renderer has been set in aTableColumn.voidsetModel(TableModel dataModel) voidsetRowSelectionAllowed(boolean rowSelectionAllowed) Sets whether the rows in this model can be selected.voidsetRowSelectionInterval(int index0, int index1) Selects the rows fromindex0toindex1, inclusive.voidsetSelectionMode(int selectionMode) Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.voidsetToolTipText(String text) Registers the text to display in a tool tip.Methods inherited from interface IComponent
addFocusListener, addKeyListener, addMouseListener, getLocationOnScreen, isEnabled, removeFocusListener, removeKeyListener, removeMouseListener, repaint, setEnabledMethods inherited from interface IContainer
add, add, addContainerListener, getComponentAt, getLayout, removeContainerListener, setLayoutMethods inherited from interface IJComponent
addPropertyChangeListener, addPropertyChangeListener, getClientProperty, getComponentPopupMenu, putClientProperty, removePropertyChangeListener, removePropertyChangeListener, setBorder, setTransferHandler, updateUI
-
Method Details
-
convertRowIndexToView
int convertRowIndexToView(int i) -
convertRowIndexToModel
int convertRowIndexToModel(int i) -
convertColumnIndexToView
int convertColumnIndexToView(int i) -
convertColumnIndexToModel
int convertColumnIndexToModel(int i) -
setModel
-
getModel
TableModel getModel() -
getComponent
Component getComponent() -
setSelectionMode
void setSelectionMode(int selectionMode) Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.Note:
JTableprovides all the methods for handling column and row selection. When setting states, such assetSelectionMode, it not only updates the mode for the row selection model but also sets similar values in the selection model of thecolumnModel. If you want to have the row and column selection models operating in different modes, set them both directly.Both the row and column selection models for
JTabledefault to using aDefaultListSelectionModelso thatJTableworks the same way as theJList. See thesetSelectionModemethod inJListfor details about the modes.- See Also:
-
setRowSelectionAllowed
void setRowSelectionAllowed(boolean rowSelectionAllowed) Sets whether the rows in this model can be selected.- Parameters:
rowSelectionAllowed- true if this model will allow row selection bound: true attribute: visualUpdate true description: If true, an entire row is selected for each selected cell.
-
getSelectionModel
ListSelectionModel getSelectionModel()Returns theListSelectionModelthat is used to maintain row selection state.- Returns:
- the object that provides row selection state,
nullif row selection is not allowed
-
getSelectedRow
int getSelectedRow()Returns the index of the first selected row, -1 if no row is selected.- Returns:
- the index of the first selected row
-
getSelectedColumn
int getSelectedColumn()Returns the index of the first selected column, -1 if no column is selected.- Returns:
- the index of the first selected column
-
setDefaultRenderer
Sets a default cell renderer to be used if no renderer has been set in aTableColumn. If renderer isnull, removes the default renderer for this column class.- Parameters:
columnClass- set the default cell renderer for this columnClassrenderer- default cell renderer to be used for this columnClass
-
setRowSelectionInterval
void setRowSelectionInterval(int index0, int index1) Selects the rows fromindex0toindex1, inclusive.- Parameters:
index0- one end of the intervalindex1- the other end of the interval- Throws:
IllegalArgumentException- ifindex0orindex1lie outside [0,getRowCount()-1]
-
getCellRect
Returns a rectangle for the cell that lies at the intersection ofrowandcolumn. IfincludeSpacingis true then the value returned has the full height and width of the row and column specified. If it is false, the returned rectangle is inset by the intercell spacing to return the true bounds of the rendering or editing component as it will be set during rendering.If the column index is valid but the row index is less than zero the method returns a rectangle with the
yandheightvalues set appropriately and thexandwidthvalues both set to zero. In general, when either the row or column indices indicate a cell outside the appropriate range, the method returns a rectangle depicting the closest edge of the closest cell that is within the table's range. When both row and column indices are out of range the returned rectangle covers the closest point of the closest cell.In all cases, calculations that use this method to calculate results along one axis will not fail because of anomalies in calculations along the other axis. When the cell is not valid the
includeSpacingparameter is ignored.- Parameters:
row- the row index where the desired cell is locatedcolumn- the column index where the desired cell is located in the display; this is not necessarily the same as the column index in the data model for the table; theconvertColumnIndexToView(int)method may be used to convert a data model column index to a display column indexincludeSpacing- if false, return the true cell bounds - computed by subtracting the intercell spacing from the height and widths of the column and row models- Returns:
- the rectangle containing the cell at location
row,column
-
columnAtPoint
Returns the index of the column thatpointlies in, or -1 if the result is not in the range [0,getColumnCount()-1].- Parameters:
point- the location of interest- Returns:
- the index of the column that
pointlies in, or -1 if the result is not in the range [0,getColumnCount()-1] - See Also:
-
rowAtPoint
Returns the index of the row thatpointlies in, or -1 if the result is not in the range [0,getRowCount()-1].- Parameters:
point- the location of interest- Returns:
- the index of the row that
pointlies in, or -1 if the result is not in the range [0,getRowCount()-1] - See Also:
-
setToolTipText
Registers the text to display in a tool tip. The text displays when the cursor lingers over the component.See How to Use Tool Tips in The Java Tutorial for further documentation.
- Parameters:
text- the string to display; if the text isnull, the tool tip is turned off for this component preferred: true description: The text to display in a tool tip.
-
getColumnModel
TableColumnModel getColumnModel()Returns theTableColumnModelthat contains all column information of this table.- Returns:
- the object that provides the column state of the table
-
getSelectedRows
int[] getSelectedRows()Returns the indices of all selected rows.- Returns:
- an array of integers containing the indices of all selected rows, or an empty array if no row is selected
- See Also:
-