Example usage for Java javax.swing JTable fields, constructors, methods, implement or subclass
The text is from its open source code.
int | AUTO_RESIZE_OFF Do not adjust column widths automatically; use a horizontal scrollbar instead. |
int | AUTO_RESIZE_NEXT_COLUMN When a column is adjusted in the UI, adjust the next column the opposite way. |
int | AUTO_RESIZE_SUBSEQUENT_COLUMNS During UI adjustment, change subsequent columns to preserve the total width; this is the default behavior. |
int | AUTO_RESIZE_LAST_COLUMN During all resize operations, apply adjustments to the last column only. |
int | AUTO_RESIZE_ALL_COLUMNS During all resize operations, proportionately resize all columns. |
JTable() Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model. | |
JTable(TableModel dm, TableColumnModel cm) Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model. | |
JTable(int numRows, int numColumns) Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel . | |
JTable(Vector extends Vector> rowData, Vector> columnNames) Constructs a JTable to display the values in the Vector of Vectors , rowData , with column names, columnNames . | |
JTable(final Object[][] rowData, final Object[] columnNames) Constructs a JTable to display the values in the two dimensional array, rowData , with column names, columnNames . | |
JTable(TableModel dm) Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model. |
Component | add(Component comp) Appends the specified component to the end of this container. |
void | addColumn(TableColumn aColumn) Appends aColumn to the end of the array of columns held by this JTable 's column model. |
void | addColumnSelectionInterval(int index0, int index1) Adds the columns from index0 to index1 , inclusive, to the current selection. |
void | addComponentListener(ComponentListener l) Adds the specified component listener to receive component events from this component. |
void | addFocusListener(FocusListener l) Adds the specified focus listener to receive focus events from this component when this component gains input focus. |
void | addKeyListener(KeyListener l) Adds the specified key listener to receive key events from this component. |
void | addMouseListener(MouseListener l) Adds the specified mouse listener to receive mouse events from this component. |
void | addMouseMotionListener(MouseMotionListener l) Adds the specified mouse motion listener to receive mouse motion events from this component. |
void | addNotify() Calls the configureEnclosingScrollPane method. |
void | addRowSelectionInterval(int index0, int index1) Adds the rows from index0 to index1 , inclusive, to the current selection. |
void | changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) Updates the selection models of the table, depending on the state of the two flags: toggle and extend . |
void | clearSelection() Deselects all selected columns and rows. |
int | columnAtPoint(Point point) Returns the index of the column that point lies in, or -1 if the result is not in the range [0, getColumnCount() -1]. |
int | convertColumnIndexToModel(int viewColumnIndex) Maps the index of the column in the view at viewColumnIndex to the index of the column in the table model. |
int | convertColumnIndexToView(int modelColumnIndex) Maps the index of the column in the table model at modelColumnIndex to the index of the column in the view. |
int | convertRowIndexToModel(int viewRowIndex) Maps the index of the row in terms of the view to the underlying TableModel . |
int | convertRowIndexToView(int modelRowIndex) Maps the index of the row in terms of the TableModel to the view. |
void | createDefaultColumnsFromModel() Creates default columns for the table from the data model using the getColumnCount method defined in the TableModel interface. |
void | doLayout() Causes this table to lay out its rows and columns. |
boolean | editCellAt(int row, int column) Programmatically starts editing the cell at row and column , if those indices are in the valid range, and the cell at those indices is editable. |
void | editingStopped(ChangeEvent e) Invoked when editing is finished. |
boolean | equals(Object obj) Indicates whether some other object is "equal to" this one. |
ActionMap | getActionMap() Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding. |
boolean | getAutoCreateColumnsFromModel() Determines whether the table will create default columns from the model. |
int | getAutoResizeMode() Returns the auto resize mode of the table. |
boolean | getAutoscrolls() Gets the autoscrolls property. |
Color | getBackground() Gets the background color of this component. |
Border | getBorder() Returns the border of this component or null if no border is currently set. |
Rectangle | getBounds() Gets the bounds of this component in the form of a Rectangle object. |
TableCellEditor | getCellEditor() Returns the active cell editor, which is null if the table is not currently editing. |
TableCellEditor | getCellEditor(int row, int column) Returns an appropriate editor for the cell specified by row and column . |
Rectangle | getCellRect(int row, int column, boolean includeSpacing) Returns a rectangle for the cell that lies at the intersection of row and column . |
TableCellRenderer | getCellRenderer(int row, int column) Returns an appropriate renderer for the cell specified by this row and column. |
boolean | getCellSelectionEnabled() Returns true if both row and column selection models are enabled. |
Object | getClientProperty(Object key) Returns the value of the property with the specified key. |
TableColumn | getColumn(Object identifier) Returns the TableColumn object for the column in the table whose identifier is equal to identifier , when compared using equals . |
Class> | getColumnClass(int column) Returns the type of the column appearing in the view at column position column . |
int | getColumnCount() Returns the number of columns in the column model. |
TableColumnModel | getColumnModel() Returns the TableColumnModel that contains all column information of this table. |
String | getColumnName(int column) Returns the name of the column appearing in the view at column position column . |
boolean | getColumnSelectionAllowed() Returns true if columns can be selected. |
TableCellEditor | getDefaultEditor(Class> columnClass) Returns the editor to be used when no editor has been set in a TableColumn . |
TableCellRenderer | getDefaultRenderer(Class> columnClass) Returns the cell renderer to be used when no renderer has been set in a TableColumn . |
int | getEditingColumn() Returns the index of the column that contains the cell currently being edited. |
int | getEditingRow() Returns the index of the row that contains the cell currently being edited. |
Component | getEditorComponent() Returns the component that is handling the editing session. |
Font | getFont() Gets the font of this component. |
FontMetrics | getFontMetrics(Font font) Gets the FontMetrics for the specified Font . |
Color | getForeground() Gets the foreground color of this component. |
Graphics | getGraphics() Returns this component's graphics context, which lets you draw on a component. |
int | getHeight() Returns the current height of this component. |
InputMap | getInputMap(int condition) Returns the InputMap that is used during condition . |
Insets | getInsets() If a border has been set on this component, returns the border's insets; otherwise calls super.getInsets . |
Dimension | getIntercellSpacing() Returns the horizontal and vertical space between cells. |
Locale | getLocale() Gets the locale of this component. |
Point | getLocationOnScreen() Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space. |
Dimension | getMaximumSize() If the maximum size has been set to a non- null value just returns it. |
TableModel | getModel() Returns the TableModel that provides the data displayed by this JTable . |
MouseListener[] | getMouseListeners() Returns an array of all the mouse listeners registered on this component. |
String | getName() Gets the name of the component. |
Container | getParent() Gets the parent of this component. |
Dimension | getPreferredScrollableViewportSize() Returns the preferred size of the viewport for this table. |
Dimension | getPreferredSize() If the preferredSize has been set to a non-null value just returns it. |
int | getRowCount() Returns the number of rows that can be shown in the JTable , given unlimited space. |
int | getRowHeight() Returns the height of a table row, in pixels. |
int | getRowHeight(int row) Returns the height, in pixels, of the cells in row . |
int | getRowMargin() Gets the amount of empty space, in pixels, between cells. |
boolean | getRowSelectionAllowed() Returns true if rows can be selected. |
RowSorter extends TableModel> | getRowSorter() Returns the object responsible for sorting. |
int | getSelectedColumn() Returns the index of the first selected column, -1 if no column is selected. |
int | getSelectedColumnCount() Returns the number of selected columns. |
int[] | getSelectedColumns() Returns the indices of all selected columns. |
int | getSelectedRow() Returns the index of the first selected row, -1 if no row is selected. |
int | getSelectedRowCount() Returns the number of selected rows. |
int[] | getSelectedRows() Returns the indices of all selected rows. |
Color | getSelectionBackground() Returns the background color for selected cells. |
Color | getSelectionForeground() Returns the foreground color for selected cells. |
ListSelectionModel | getSelectionModel() Returns the ListSelectionModel that is used to maintain row selection state. |
Dimension | getSize() Returns the size of this component in the form of a Dimension object. |
JTableHeader | getTableHeader() Returns the tableHeader used by this JTable . |
Object | getValueAt(int row, int column) Returns the cell value at row and column . |
Rectangle | getVisibleRect() Returns the Component 's "visible rectangle" - the intersection of this component's visible rectangle, new Rectangle(0, 0, getWidth(), getHeight()) , and all of its ancestors' visible rectangles. |
int | getWidth() Returns the current width of this component. |
boolean | isCellEditable(int row, int column) Returns true if the cell at row and column is editable. |
boolean | isCellSelected(int row, int column) Returns true if the specified indices are in the valid range of rows and columns and the cell at the specified position is selected. |
boolean | isEditing() Returns true if a cell is being edited. |
boolean | isEnabled() Determines whether this component is enabled. |
boolean | isOpaque() Returns true if this component is completely opaque. |
boolean | isRowSelected(int row) Returns true if the specified index is in the valid range of rows, and the row at that index is selected. |
void | moveColumn(int column, int targetColumn) Moves the column column to the position currently occupied by the column targetColumn in the view. |
void | paint(Graphics g) Invoked by Swing to draw components. |
Component | prepareRenderer(TableCellRenderer renderer, int row, int column) Prepares the renderer by querying the data model for the value and selection state of the cell at row , column . |
boolean | print() A convenience method that displays a printing dialog, and then prints this JTable in mode PrintMode.FIT_WIDTH , with no header or footer text. |
boolean | print(PrintMode printMode) A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with no header or footer text. |
boolean | print(PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat) A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with the specified header and footer text. |
boolean | print(PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat, boolean showPrintDialog, PrintRequestAttributeSet attr, boolean interactive) Prints this table, as specified by the fully featured #print(JTable.PrintMode,MessageFormat,MessageFormat,boolean,PrintRequestAttributeSet,boolean,PrintService) print method, with the default printer specified as the print service. |
void | putClientProperty(Object key, Object value) Adds an arbitrary key/value "client property" to this component. |
void | removeColumn(TableColumn aColumn) Removes aColumn from this JTable 's array of columns. |
void | removeColumnSelectionInterval(int index0, int index1) Deselects the columns from index0 to index1 , inclusive. |
void | removeMouseListener(MouseListener l) Removes the specified mouse listener so that it no longer receives mouse events from this component. |
void | removeRowSelectionInterval(int index0, int index1) Deselects the rows from index0 to index1 , inclusive. |
void | repaint() Repaints this component. |
boolean | requestFocusInWindow() Requests that this Component gets the input focus. |
void | revalidate() Supports deferred automatic layout. |
int | rowAtPoint(Point point) Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount() -1]. |
void | scrollRectToVisible(Rectangle aRect) Forwards the scrollRectToVisible() message to the JComponent 's parent. |
void | selectAll() Selects all rows, columns, and cells in the table. |
void | setAlignmentX(float alignmentX) Sets the horizontal alignment. |
void | setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel) Sets this table's autoCreateColumnsFromModel flag. |
void | setAutoCreateRowSorter(boolean autoCreateRowSorter) Specifies whether a RowSorter should be created for the table whenever its model changes. |
void | setAutoResizeMode(int mode) Sets the table's auto resize mode when the table is resized. |
void | setBackground(Color bg) Sets the background color of this component. |
void | setBorder(Border border) Sets the border of this component. |
void | setBounds(int x, int y, int width, int height) Moves and resizes this component. |
void | setBounds(Rectangle r) Moves and resizes this component to conform to the new bounding rectangle r . |
void | setCellEditor(TableCellEditor anEditor) Sets the active cell editor. |
void | setCellSelectionEnabled(boolean cellSelectionEnabled) Sets whether this table allows both a column selection and a row selection to exist simultaneously. |
void | setColumnModel(final TableColumnModel columnModel) Sets the column model for this table to columnModel and registers for listener notifications from the new column model. |
void | setColumnSelectionAllowed(boolean columnSelectionAllowed) Sets whether the columns in this model can be selected. |
void | setColumnSelectionInterval(int index0, int index1) Selects the columns from index0 to index1 , inclusive. |
void | setComponentOrientation(ComponentOrientation o) Sets the language-sensitive orientation that is to be used to order the elements or text within this component. |
void | setComponentPopupMenu(JPopupMenu popup) Sets the JPopupMenu for this JComponent . |
void | setCursor(Cursor cursor) Sets the cursor image to the specified cursor. |
void | setDefaultEditor(Class> columnClass, TableCellEditor editor) Sets a default cell editor to be used if no editor has been set in a TableColumn . |
void | setDefaultRenderer(Class> columnClass, TableCellRenderer renderer) Sets a default cell renderer to be used if no renderer has been set in a TableColumn . |
void | setDoubleBuffered(boolean aFlag) Sets whether this component should use a buffer to paint. |
void | setDragEnabled(boolean b) Turns on or off automatic drag handling. |
void | setDropMode(DropMode dropMode) Sets the drop mode for this component. |
void | setDropTarget(DropTarget dt) Associate a DropTarget with this component. |
void | setEnabled(boolean enabled) Sets whether or not this component is enabled. |
void | setFillsViewportHeight(boolean fillsViewportHeight) Sets whether or not this table is always made large enough to fill the height of an enclosing viewport. |
void | setFocusable(boolean focusable) Sets the focusable state of this Component to the specified value. |
void | setFocusTraversalKeys(int id, Set extends AWTKeyStroke> keystrokes) Sets the focus traversal keys for a given traversal operation for this Component. |
void | setFont(Font font) Sets the font for this component. |
void | setForeground(Color fg) Sets the foreground color of this component. |
void | setGridColor(Color gridColor) Sets the color used to draw grid lines to gridColor and redisplays. |
void | setIntercellSpacing(Dimension intercellSpacing) Sets the rowMargin and the columnMargin -- the height and width of the space between cells -- to intercellSpacing . |
void | setMaximumSize(Dimension maximumSize) Sets the maximum size of this component to a constant value. |
void | setModel(final TableModel dataModel) Sets the data model for this table to dataModel and registers with it for listener notifications from the new data model. |
void | setName(String name) Sets the name of the component to the specified string. |
void | setOpaque(boolean isOpaque) If true the component paints every pixel within its bounds. |
void | setPreferredScrollableViewportSize(Dimension size) Sets the preferred size of the viewport for this table. |
void | setPreferredSize(Dimension preferredSize) Sets the preferred size of this component. |
void | setRowHeight(int rowHeight) Sets the height, in pixels, of all cells to rowHeight , revalidates, and repaints. |
void | setRowHeight(int row, int rowHeight) Sets the height for row to rowHeight , revalidates, and repaints. |
void | setRowMargin(int rowMargin) Sets the amount of empty space between cells in adjacent rows. |
void | setRowSelectionAllowed(boolean rowSelectionAllowed) Sets whether the rows in this model can be selected. |
void | setRowSelectionInterval(int index0, int index1) Selects the rows from index0 to index1 , inclusive. |
void | setRowSorter(RowSorter extends TableModel> sorter) Sets the RowSorter . |
void | setSelectionBackground(Color selectionBackground) Sets the background color for selected cells. |
void | setSelectionMode(int selectionMode) Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals. |
void | setSelectionModel(final ListSelectionModel selectionModel) Sets the row selection model for this table to selectionModel and registers for listener notifications from the new selection model. |
void | setShowGrid(boolean showGrid) Sets whether the table draws grid lines around cells. |
void | setShowHorizontalLines(boolean showHorizontalLines) Sets whether the table draws horizontal lines between cells. |
void | setShowVerticalLines(boolean showVerticalLines) Sets whether the table draws vertical lines between cells. |
void | setSurrendersFocusOnKeystroke(boolean surrendersFocusOnKeystroke) Sets whether editors in this JTable get the keyboard focus when an editor is activated as a result of the JTable forwarding keyboard events for a cell. |
void | setTableHeader(JTableHeader tableHeader) Sets the tableHeader working with this JTable to newHeader . |
void | setToolTipText(String text) Registers the text to display in a tool tip. |
void | setTransferHandler(TransferHandler newHandler) Sets the TransferHandler , which provides support for transfer of data into and out of this component via cut/copy/paste and drag and drop. |
void | setUpdateSelectionOnSort(boolean update) Specifies whether the selection should be updated after sorting. |
void | setValueAt(Object aValue, int row, int column) Sets the value for the cell in the table model at row and column . |
void | setVisible(boolean aFlag) Makes the component visible or invisible. |
void | tableChanged(TableModelEvent e) Invoked when this table's TableModel generates a TableModelEvent . |
void | update(Graphics g) Calls paint . |
void | updateUI() Notification from the UIManager that the L&F has changed. |
void | validate() Validates this container and all of its subcomponents. |