|
JIDE 2.9.5 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
com.jidesoft.grid.JideTable
public class JideTable
JideTable is an extended version of JTable.
JideTable.
First, we added CellEditorListener support. You can add a JideCellEditorListener to the table.
JideCellEditorListener extends CellEditorListener and added additional methods such as
JideCellEditorListener.editingStarting(javax.swing.event.ChangeEvent), JideCellEditorListener.editingStopping(javax.swing.event.ChangeEvent) and CellEditorListener.editingStopped(javax.swing.event.ChangeEvent). You can do things like preventing cell from
starting edit or preventing cell from stopping edit.
The second feature is to support Validator. You can add a Validator to the table. The validating() method in the
listener will be called before cell stops editing. If the validation failed, the cell editor won't be removed.
The third feature added to JideTable is the support of the listener for row height changes when rows have various
height. You can add a listener by calling getRowHeights().addRowHeightChangeListener(listener). A RowHeightChangeEvent will be fired whenever setRowHeight(int,int) is called.
The fourth feature is rowAutoResizes. By default, JTable's row height is determined explicitly. It wouldn't consider
the cell content preferred height. There is a problem here if a cell renderer can support multiple lines. So we added
a new attribute called rowAutoResizes. By default, it's false which is exactly the same behavior as JTable. If you
set to true, the table row will resize automatically when cell renderer's preferred height changes. Please note there
is a performance hit if you turned it on as it has to check all cells to find out the preferred row height. So only
use it when it's really necessary.
In the future, we will add more features to JideTable as long as we think the feature should be part of
the base table class.
Please be noted that, JideTable could NOT support the sorter provided in JTable. The reason is that, JTable contains
many private method and fields in that area, which prevents us to inherit its behavior. For sorting feature in JideTable,
please use SortableTable instead.
| Nested Class Summary | |
|---|---|
protected static class |
JideTable.NonContiguousTransferHandler
|
| Nested classes/interfaces inherited from class javax.swing.JTable |
|---|
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JideTable()
|
|
JideTable(int numRows,
int numColumns)
|
|
JideTable(Object[][] rowData,
Object[] columnNames)
|
|
JideTable(TableModel dm)
|
|
JideTable(TableModel dm,
TableColumnModel cm)
|
|
JideTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
|
|
JideTable(Vector<?> rowData,
Vector<?> columnNames)
|
|
| Method Summary | |
|---|---|
void |
addCellEditorListener(JideCellEditorListener l)
Adds a JideCellEditorListener to the listener list. |
void |
addColumn(TableColumn column)
Overrides this method to skip the column that is being added when the column was hidden earlier by TableColumnChooser.hideColumn(javax.swing.JTable, int) method. |
void |
addNotify()
|
void |
addRowValidator(RowValidator l)
Adds a RowValidator to the listener list. |
void |
addValidator(Validator l)
Adds a Validator to the listener list. |
void |
adjustSelectionWhenColumnMoved(int column,
int targetColumn)
Usually you don't need to call this method. |
boolean |
alwaysCalculateCellRect()
A boolean flag to determine if the rect should always be calculated when painting the grid line and cells. |
protected void |
calculateAutoResizedRowHeights()
|
protected void |
calculateAutoResizedRowHeights(int firstRow,
int lastRow)
|
protected int |
calculateRowHeight(int row)
The method calculates the height for the row based on the content in the row. |
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()
|
void |
clearSelectionPermanently()
Clear the selections permanently without being restored later on. |
void |
columnAdded(TableColumnModelEvent e)
|
void |
columnMoved(TableColumnModelEvent e)
|
void |
columnRemoved(TableColumnModelEvent e)
|
void |
configureEnclosingScrollPaneExplicitly()
|
protected String |
convertElementToString(Object value,
int row,
int column)
Get the displayed string of the specified value in designated row and column. |
int |
convertRowIndexToModel(int viewRowIndex)
Overrides this methods so that it is available for pre-JDK6 environment. |
int |
convertRowIndexToView(int modelRowIndex)
Overrides this methods so that it is available for pre-JDK6 environment. |
void |
createDefaultColumnsFromModel()
|
protected ListSelectionModel |
createDefaultSelectionModel()
|
protected JTableHeader |
createDefaultTableHeader()
Creates the table header. |
void |
createDefaultTableSelectionModel()
Creates a default TableSelectionModel. |
protected RowHeightChangeListener |
createRowAutoScrollingListener()
Creates the RowHeightChangeListener which will automatically scroll the row then row height changes
so that it is outside the visible area. |
protected RowHeights |
createRowHeights()
|
protected SortTableHeaderRenderer |
createSortHeaderRenderer()
Creates the header renderer. |
boolean |
editCellAt(int row,
int column,
EventObject e)
|
void |
editingCanceled(ChangeEvent e)
|
void |
editingStopped(ChangeEvent e)
|
protected void |
fireEditingCanceled(Object source,
int row,
int column)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireEditingStarted(Object source,
int row,
int column)
Notifies all listeners that have registered interest for notification on this event type. |
protected boolean |
fireEditingStarting(Object source,
int row,
int column)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireEditingStopped(Object source,
int row,
int column)
Notifies all listeners that have registered interest for notification on this event type. |
protected boolean |
fireEditingStopping(Object source,
int row,
int column)
Notifies all listeners that have registered interest for notification on this event type. |
int |
getAutoResizeMode()
|
CellEditorListener[] |
getCellEditorListeners()
Returns an array of all the JideCellEditorListeners added to this JideTable with
addCellEditorListener(). |
Rectangle |
getCellRect(int row,
int column,
boolean includeSpacing)
|
int |
getClickCountToStart()
Returns the number of clicks needed to start editing. |
int |
getEditorAutoCompletionMode()
Gets the editor auto-completion mode. |
Rectangle |
getEditorCellRect(int rowIndex,
int columnIndex)
In TreeTable and HierarchicalTable case, the cell rect for cell editor should consider the +/- icon size so the cell editor doesn't cover the +/- icon. |
Color |
getGridColor(int row)
Gets the grid line color for each row. |
int |
getRowHeight(int row)
|
RowHeights |
getRowHeights()
|
RowValidator[] |
getRowValidator()
Returns an array of all the RowValidators added to this AbstractCellEditor with
addValidationListener(). |
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()
|
TableColumnWidthKeeper |
getTableColumnWidthKeeper()
|
String |
getTableHeaderToolTipText(int columnIndex)
Gets the TableHeader's tooltip for a particular view column index |
String |
getTableHeaderToolTipText(MouseEvent event)
Gets the TableHeader's tooltip at the location of mouse event. |
TableSelectionModel |
getTableSelectionModel()
Gets the table selection model. |
JTextComponent |
getTextComponentForEditorComponent(Component component)
Gets the text component from the editor component. |
String |
getToolTipText(MouseEvent event)
|
TransferHandler |
getTransferHandler()
Overrides this method to provide our own TransferHandler if isNonContiguousCellSelection() is true only if the original TransferHandler is an instance of UIResource. |
String |
getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component. |
Validator[] |
getValidator()
Returns an array of all the Validators added to this AbstractCellEditor with
addValidationListener(). |
Color |
getVerticalGridColor(int column)
Gets the grid line color for each column. |
void |
indexChanged(IndexChangeEvent event)
Called whenever the table model wrapper is going to have some change. |
protected void |
initTable()
Leaves it here for backward compatible reason. |
boolean |
isAlwaysRequestFocusForEditor()
Get the flag indicating if JideTable should always request focus for cell editor. |
boolean |
isAutoSelectTextWhenStartsEditing()
Checks if the text in the cell editor will be selected when cell starts editing. |
boolean |
isAutoStartCellEditing()
Checks if the navigation key stroke will start cell editing. |
protected boolean |
isAutoStartCellEditingKey(KeyStroke ks)
Checks if the key stroke will trigger the cell editing. |
protected boolean |
isBatchProcessing()
Checks if it is in batch processing. |
boolean |
isCalculateRowHeightsOnWidthChange()
Get the flag indicating if JideTable should calculate row heights if column width is changed. |
boolean |
isCellContentVisible()
Checks if the table cell content will be painted. |
protected boolean |
isCellFocused(int rowIndex,
int columnIndex)
Check if the cell is a focused cell inside the table. |
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 |
isClearPropertyAtStructureChange()
Get the flag indicating if JideTable should clear properties for table column orders. |
boolean |
isClearSelectionOnTableDataChanges()
Checks if the selection should be cleared when tableDataChanged event is fired. |
boolean |
isColumnAutoResizable()
Checks if the column is auto-resizable. |
boolean |
isColumnResizable()
Checks if the column is resizable by dragging the vertical grid line. |
boolean |
isColumnSelected(int column)
Returns true if the specified index is in the valid range of columns, and the column at that index is selected. |
boolean |
isEnableIgnored()
Get the flag indicating if the cell will be painted with normal text color even the table is disabled. |
boolean |
isKeepRowHeights()
Get if you want to keep row heights after table events, such as sorting and filtering. |
boolean |
isNestedTableHeader()
Checks if nested table header is used. |
boolean |
isNonContiguousCellSelection()
Checks if the table selection model allows non-contiguous cell selection. |
boolean |
isRowAutoResizes()
Checks if row automatically resizes with the cells preferred heights. |
protected boolean |
isRowHeightChanged(int row,
int newHeight)
The method will check if the new height is different with current height. |
boolean |
isRowResizable()
Checks if the row is resizable by dragging the horizontal grid line. |
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. |
boolean |
isScrollRowWhenRowHeightChanges()
Checks the flag whether a row is scrolled to visible when its height changes. |
boolean |
isSelectInsertedRows()
Returns the selectInsertedRows flag. |
boolean |
isTablePrinting()
Checks if the table is printing. |
protected boolean |
isValidCellEditingKey(KeyEvent keyEvent)
Checks if the key event is a valid keystroke to start cell editing. |
boolean |
isVariousRowHeights()
Is the table has various row height on each row. |
protected void |
loadTableRowSettings(boolean invokeOutside)
To load row heights and selections after you do some big work, like firing table data change event. |
void |
paintCellOverlay(Graphics g,
Component component,
int row,
int column,
Rectangle cellRect)
Paints the cell overlay. |
protected void |
paintFillHeader(Graphics g)
Paint fill header in the right side of the table header if needed. |
Component |
prepareEditor(TableCellEditor editor,
int row,
int column)
|
Component |
prepareRenderer(TableCellRenderer renderer,
int row,
int column)
|
boolean |
processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed)
|
void |
releaseRendererComponent(TableCellRenderer renderer,
int row,
int column,
Component component)
|
void |
removeCellEditorListener(JideCellEditorListener l)
Removes a JideCellEditorListener from the listener list. |
void |
removeEditor()
Override to regain focus on JTable when the AbstractComboBox's popup panel has focus. |
void |
removeNotify()
|
void |
removeRowValidator(RowValidator l)
Removes a RowValidator from the listener list. |
void |
removeValidator(Validator l)
Removes a Validator from the listener list. |
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]. |
protected void |
saveTableRowSettings(boolean invokeOutside)
To save row heights and selections before you do some big work, like firing table data change event. |
void |
scrollRowToVisible(int row)
Scroll the row till the row is visible. |
void |
selectAll()
|
void |
setAlwaysRequestFocusForEditor(boolean alwaysRequestFocusForEditor)
Set the flag indicating if JideTable should always request focus for cell editor. |
void |
setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized. |
void |
setAutoSelectTextWhenStartsEditing(boolean autoSelectTextWhenStartsEditing)
Sets the flag if the text in the cell editor will be selected when starts editing. |
void |
setAutoStartCellEditing(boolean autoStartCellEditing)
Sets the flag if the navigation key stroke will start cell editing. |
protected void |
setBatchProcessing(boolean batchProcessing)
Sets to batch processing. |
void |
setCalculateRowHeightsOnWidthChange(boolean calculateRowHeightsOnWidthChange)
Set the flag indicating if JideTable should calculate row heights if column width is changed. |
void |
setCellContentVisible(boolean cellContentVisible)
Sets the cell content visible or invisible. |
void |
setClearPropertyAtStructureChange(boolean clearPropertyAtStructureChange)
Set the flag indicating if JideTable should clear properties for table column orders. |
void |
setClearSelectionOnTableDataChanges(boolean clearSelectionOnTableDataChanges)
Sets the clearSelectionOnTableDataChanges attribute. |
void |
setClickCountToStart(int count)
Specifies the number of clicks needed to start editing. |
void |
setColumnAutoResizable(boolean resizable)
Enable or disable the column auto-resizable. |
void |
setColumnResizable(boolean resizable)
Enable or disable the column resizable. |
void |
setColumnSelectionAllowed(boolean columnSelectionAllowed)
Sets whether the columns can be selected. |
void |
setEditorAutoCompletionMode(int editorAutoCompletionMode)
Sets the editor auto-completion mode. |
void |
setEnabled(boolean enabled)
|
void |
setEnableIgnored(boolean enableIgnored)
Set the flag indicating if the cell will be painted with the normal text color even the table is disabled. |
void |
setKeepRowHeights(boolean keepRowHeights)
Set if you want to keep row heights after table events, such as sorting and filtering. |
void |
setModel(TableModel dataModel)
|
void |
setNestedTableHeader(boolean nestedTableHeader)
Sets if nested table header is allowed. |
void |
setNonContiguousCellSelection(boolean nonContiguousCellSelection)
Sets the attribute of nonContiguousCellSelection. |
void |
setPreferredSize(Dimension preferredSize)
|
void |
setRowAutoResizes(boolean rowAutoResizes)
Sets the rowAutoResizes attribute. |
void |
setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells to rowHeight, re-validates, and repaints. |
void |
setRowHeight(int row,
int rowHeight)
Sets the height for row to rowHeight, re-validates, and repaints. |
void |
setRowHeights(RowHeights rowHeights)
|
void |
setRowResizable(boolean resizable)
Enable or disable the row resizable. |
void |
setRowSelectionAllowed(boolean rowSelectionAllowed)
Sets whether the rows can be selected. |
void |
setScrollRowWhenRowHeightChanges(boolean scrollRowWhenRowHeightChanges)
Sets the flag if the row should be scrolled to visible when the row height changes. |
void |
setSelectInsertedRows(boolean selectInsertedRows)
Sets the selectInsertedRow flag. |
protected void |
setSortTableHeaderRenderer()
JideTable allows you to have multiple lines in table header. |
void |
setTableColumnWidthKeeper(TableColumnWidthKeeper tableColumnWidthKeeper)
|
void |
setTablePrinting(boolean tablePrinting)
Sets the table as printing. |
void |
setTableSelectionModel(TableSelectionModel tableSelectionModel)
Sets a new TableSelectionModel. |
void |
setVariousRowHeights(boolean variousRowHeights)
Sets variousRowHeights. |
protected boolean |
startCellEditing(CellEditor editor,
int row,
int column)
Calls fireEditingStarting and fireEditingStarted, and returns true or false based on
the return value of fireEditingStarting. |
void |
tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates a TableModelEvent. |
void |
updateUI()
Resets the UI property to a value from the current look and feel. |
ValidationResult |
validate(int rowIndex,
int columnIndex,
Object oldValue,
Object newValue)
|
ValidationResult |
validateRow(int rowIndex)
Validates a row. |
void |
valueChanged(ListSelectionEvent e)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.jidesoft.grid.TableAdapter |
|---|
getCellSelectionEnabled, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getRowCount, getRowSelectionAllowed, getValueAt, isCellEditable, setCellSelectionEnabled, setValueAt |
| Field Detail |
|---|
protected transient CellChangeEvent _cellChangeEvent
@Deprecated public static final String ROW_AUTO_RESIZES_PROPERTY
public static final String PROPERTY_ROW_AUTO_RESIZES
public static final String PROPERTY_NON_CONTIGUOUS_CELL_SELECTION
public static final String PROPERTY_TABLE_SELECTION_MODEL
public static final String PROPERTY_SCROLL_ROW_WHEN_ROW_HEIGHT_CHANGES
public static final String PROPERTY_CLEAR_SELECTION_ON_TABLE_DATA_CHANGES
public static final String PROPERTY_EDITOR_AUTO_COMPLETION_MODE
public static final int AUTO_RESIZE_FILL
@Deprecated public static final int AUTO_RESIZE_NEXT_COLUMN_FILL
@Deprecated public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS_FILL
@Deprecated public static final int AUTO_RESIZE_LAST_COLUMN_FILL
@Deprecated public static final int AUTO_RESIZE_ALL_COLUMNS_FILL
protected int _clickCountToStart
clickCountToStart is
defined as zero, it will not initiate until a click occurs.
protected MouseMotionListener _headerDraggingMouseMotionListener
public static final int EDITOR_AUTO_COMPLETION_MODE_NONE
public static final int EDITOR_AUTO_COMPLETION_MODE_COLUMN
public static final int EDITOR_AUTO_COMPLETION_MODE_ROW
public static final int EDITOR_AUTO_COMPLETION_MODE_TABLE
protected RowHeights _rowHeights
protected boolean _batchProcessing
protected TableColumnAutoResizer _columnAutoResizer
protected TableRowResizer _rowResizer
protected TableColumnResizer _columnResizer
| Constructor Detail |
|---|
public JideTable()
public JideTable(int numRows,
int numColumns)
public JideTable(TableModel dm)
public JideTable(Object[][] rowData,
Object[] columnNames)
public JideTable(Vector<?> rowData,
Vector<?> columnNames)
public JideTable(TableModel dm,
TableColumnModel cm)
public JideTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
| Method Detail |
|---|
protected void initTable()
public void setModel(TableModel dataModel)
setModel in class JTablepublic void setAutoResizeMode(int mode)
setAutoResizeMode in class JTablemode - the auto resize modegetAutoResizeMode(),
JTable.doLayout()public int getAutoResizeMode()
getAutoResizeMode in class JTablepublic void updateUI()
updateUI in class JTableJComponent.updateUI()public String getUIClassID()
getUIClassID in class JTableJComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)public boolean isNestedTableHeader()
setNestedTableHeader(boolean) and pass in true.
public void setNestedTableHeader(boolean nestedTableHeader)
nestedTableHeader - true or false.protected JTableHeader createDefaultTableHeader()
createDefaultTableHeader in class JTableprotected void paintFillHeader(Graphics g)
g - the Graphics instancepublic String getTableHeaderToolTipText(MouseEvent event)
event - the mouse event.
public String getTableHeaderToolTipText(int columnIndex)
columnIndex - the view column index.
public boolean processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed)
processKeyBinding in class JTable
public Component prepareEditor(TableCellEditor editor,
int row,
int column)
prepareEditor in class JTable
protected String convertElementToString(Object value,
int row,
int column)
value - the cell valuerow - the row of the cellcolumn - the column of the cell
public JTextComponent getTextComponentForEditorComponent(Component component)
isAutoSelectTextWhenStartsEditing() is true.
Please note, this method will only return JTextComponent if the component is JTextComponent, JComboBox,
AbstractComboBox or JSpinner. For all other types of components, it will return null. If you have a custom
component which also has JTextComponent in it, you would need to override this method to return the right
JTextComponent.
component - the component.
protected boolean startCellEditing(CellEditor editor,
int row,
int column)
fireEditingStarting and fireEditingStarted, and returns true or false based on
the return value of fireEditingStarting.
editor - the editorrow - the editing rowcolumn - the editing column
protected boolean fireEditingStarting(Object source,
int row,
int column)
source - the source of the eventrow - the row indexcolumn - the column index
editingStarting(), it will return true. If
one of the listener returns false, it will return false.
protected void fireEditingStarted(Object source,
int row,
int column)
source - the source of the eventrow - the row indexcolumn - the column indexEventListenerListpublic void addCellEditorListener(JideCellEditorListener l)
JideCellEditorListener to the listener list.
l - the new listener to be addedpublic void removeCellEditorListener(JideCellEditorListener l)
JideCellEditorListener from the listener list.
l - the listener to be removedpublic CellEditorListener[] getCellEditorListeners()
JideCellEditorListeners added to this JideTable with
addCellEditorListener().
CellEditorListeners added or an empty array if no listeners have been addedpublic void addValidator(Validator l)
Validator to the listener list.
l - the new listener to be addedpublic void removeValidator(Validator l)
Validator from the listener list.
l - the listener to be removedpublic Validator[] getValidator()
Validators added to this AbstractCellEditor with
addValidationListener().
Validators added or an empty array if no listeners have been added
public ValidationResult validate(int rowIndex,
int columnIndex,
Object oldValue,
Object newValue)
public void addRowValidator(RowValidator l)
RowValidator to the listener list.
l - the new listener to be addedpublic void removeRowValidator(RowValidator l)
RowValidator from the listener list.
l - the listener to be removedpublic RowValidator[] getRowValidator()
RowValidators added to this AbstractCellEditor with
addValidationListener().
RowValidators added or an empty array if no listeners have been addedpublic ValidationResult validateRow(int rowIndex)
addRowValidator(com.jidesoft.validation.RowValidator)
to do the validation.
rowIndex - the row index.
public void editingStopped(ChangeEvent e)
editingStopped in interface CellEditorListenereditingStopped in class JTablepublic void editingCanceled(ChangeEvent e)
editingCanceled in interface CellEditorListenereditingCanceled in class JTable
protected boolean fireEditingStopping(Object source,
int row,
int column)
source - the source of the eventrow - the row indexcolumn - the column index
editingStarting(), it will return true. If
one of the listener returns false, it will return false.
protected void fireEditingStopped(Object source,
int row,
int column)
source - the source of the eventrow - the row indexcolumn - the column indexEventListenerList
protected void fireEditingCanceled(Object source,
int row,
int column)
source - the source of the eventrow - the row indexcolumn - the column indexEventListenerListpublic RowHeights getRowHeights()
protected RowHeights createRowHeights()
public void setRowHeights(RowHeights rowHeights)
public boolean isScrollRowWhenRowHeightChanges()
public void setScrollRowWhenRowHeightChanges(boolean scrollRowWhenRowHeightChanges)
scrollRowWhenRowHeightChanges - true or false.protected RowHeightChangeListener createRowAutoScrollingListener()
RowHeightChangeListener which will automatically scroll the row then row height changes
so that it is outside the visible area.
RowHeightChangeListener.public void scrollRowToVisible(int row)
TableUtils.ensureRowVisible(javax.swing.JTable,int)
method. It will only scroll vertically to the exact location so that the row is fully visible.
This method is called automatically when row height changes. If isScrollRowWhenRowHeightChanges() is
true, the row will automatically be scrolled to show the whole row when the height for that row changes. You can
subclass it to scroll the table in a different way.
row - the row whose height changes.public void setRowHeight(int rowHeight)
rowHeight, re-validates, and repaints. The height of the
cells will be equal to the row height minus the row margin.
setRowHeight in class JTablerowHeight - new row height
IllegalArgumentException - if rowHeight is less than 1 description: The height of the
specified row.getRowHeight(int)protected boolean isBatchProcessing()
protected void setBatchProcessing(boolean batchProcessing)
batchProcessing - true or false.
public void setRowHeight(int row,
int rowHeight)
row to rowHeight, re-validates, and repaints. The height of the
cells in this row will be equal to the row height minus the row margin.
setRowHeight in class JTablerow - the row whose height is being changedrowHeight - new row height, in pixels
IllegalArgumentException - if rowHeight is less than 1 description: The height in pixels of
the cells in row
protected void calculateAutoResizedRowHeights(int firstRow,
int lastRow)
protected void calculateAutoResizedRowHeights()
protected int calculateRowHeight(int row)
row - the row to be calculated
protected boolean isRowHeightChanged(int row,
int newHeight)
TableUtils.autoResizeRow(javax.swing.JTable, int, int).
row - the row to be checkednewHeight - new height of the row, most likely from calculateRowHeight(int)
public int getRowHeight(int row)
getRowHeight in class JTablepublic int rowAtPoint(Point point)
point lies in, or -1 if the result is not in the range [0,
getRowCount()-1].
rowAtPoint in class JTablepoint - 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)
public Rectangle getCellRect(int row,
int column,
boolean includeSpacing)
getCellRect in class JTable
public Rectangle getEditorCellRect(int rowIndex,
int columnIndex)
rowIndex - the row index.columnIndex - the column index
public void createDefaultColumnsFromModel()
createDefaultColumnsFromModel in class JTablepublic void setKeepRowHeights(boolean keepRowHeights)
isKeepRowHeights()
keepRowHeights - the flag that if the table will keep the row heightspublic boolean isKeepRowHeights()
protected void saveTableRowSettings(boolean invokeOutside)
loadTableRowSettings(boolean).
invokeOutside - always TRUE if you want to call this method explicitly. We will call this method with FALSE
internally.protected void loadTableRowSettings(boolean invokeOutside)
saveTableRowSettings(boolean).
invokeOutside - always TRUE if you want to call this method explicitly. We will call this method with FALSE
internally.public void indexChanged(IndexChangeEvent event)
indexChanged in interface IndexChangeListenerevent - the table model wrapper eventpublic void tableChanged(TableModelEvent e)
TableModel generates a TableModelEvent. The
TableModelEvent should be constructed in the coordinate system of the model; the appropriate mapping
to the view coordinate system is performed by this JTable when it receives the event.
Application code will not use these methods explicitly, they are used internally by JTable.
tableChanged in interface TableModelListenertableChanged in class JTableprotected ListSelectionModel createDefaultSelectionModel()
createDefaultSelectionModel in class JTablepublic boolean isRowAutoResizes()
public void setRowAutoResizes(boolean rowAutoResizes)
rowAutoResizes - true to enable rowAutoResizes. Otherwise false.protected void setSortTableHeaderRenderer()
JideTable table = new JideTable(model){
protected void initTable() {
super.initTable();
setSortTableHeaderRenderer();
}
protected JTableHeader createDefaultTableHeader() {
return new JTableHeader(columnModel);
}
};
Now if you have a column name that has "\n" in it, it will split the text into multiple lines.
protected SortTableHeaderRenderer createSortHeaderRenderer()
public boolean isNonContiguousCellSelection()
getTableSelectionModel() to get the selection model and add listener to it. If false,
getTableSelectionModel() will return null.public void setNonContiguousCellSelection(boolean nonContiguousCellSelection)
nonContiguousCellSelection - true to enable non-contiguous cell selection.public void setRowSelectionAllowed(boolean rowSelectionAllowed)
TableAdapter
setRowSelectionAllowed in interface TableAdaptersetRowSelectionAllowed in class JTablerowSelectionAllowed - true if it will allow row selectionpublic void setColumnSelectionAllowed(boolean columnSelectionAllowed)
TableAdapter
setColumnSelectionAllowed in interface TableAdaptersetColumnSelectionAllowed in class JTablecolumnSelectionAllowed - true if it will allow column selectionpublic void createDefaultTableSelectionModel()
public void setTableSelectionModel(TableSelectionModel tableSelectionModel)
tableSelectionModel - the new TableSelectionModel.public TableSelectionModel getTableSelectionModel()
isNonContiguousCellSelection()
return true.
public int[] getSelectedRows()
TableAdapter
getSelectedRows in interface TableAdaptergetSelectedRows in class JTableTableAdapter.getSelectedRow()public int[] getSelectedColumns()
TableAdapter
getSelectedColumns in interface TableAdaptergetSelectedColumns in class JTableTableAdapter.getSelectedColumn()public int getSelectedRow()
TableAdapter
getSelectedRow in interface TableAdaptergetSelectedRow in class JTablepublic int getSelectedColumn()
TableAdapter
getSelectedColumn in interface TableAdaptergetSelectedColumn in class JTablepublic int getSelectedRowCount()
TableAdapter
getSelectedRowCount in interface TableAdaptergetSelectedRowCount in class JTablepublic int getSelectedColumnCount()
TableAdapter
getSelectedColumnCount in interface TableAdaptergetSelectedColumnCount in class JTablepublic boolean isRowSelected(int row)
TableAdapter
isRowSelected in interface TableAdapterisRowSelected in class JTablerow - the row index
row is a valid index and the row at that index is selected (where 0 is the first
row)public boolean isColumnSelected(int column)
TableAdapter
isColumnSelected in interface TableAdapterisColumnSelected in class JTablecolumn - the column in the column model
column is a valid index and the column at that index is selected (where 0 is the
first column)
public boolean isCellSelected(int row,
int column)
TableAdapter
isCellSelected in interface TableAdapterisCellSelected in class JTablerow - the row being queriedcolumn - the column being queried
row and column are valid indices and the cell at index (row,
column) is selected, where the first row and first column are at index 0public boolean isCalculateRowHeightsOnWidthChange()
isRowAutoResizes() returns true.
The default value of this flag is true.
public void setCalculateRowHeightsOnWidthChange(boolean calculateRowHeightsOnWidthChange)
calculateRowHeightsOnWidthChange - the flagpublic boolean isAlwaysRequestFocusForEditor()
public void setAlwaysRequestFocusForEditor(boolean alwaysRequestFocusForEditor)
alwaysRequestFocusForEditor - the flagpublic boolean isClearPropertyAtStructureChange()
public void setClearPropertyAtStructureChange(boolean clearPropertyAtStructureChange)
clearPropertyAtStructureChange - the flag
public void paintCellOverlay(Graphics g,
Component component,
int row,
int column,
Rectangle cellRect)
g - the Graphicscomponent - the componentrow - the row indexcolumn - the column indexcellRect - the cell rectangle of the cell at the specified row index and column index.public boolean isEnableIgnored()
setEnableIgnored(boolean) and set it to true.
The default value is false.
public void setEnableIgnored(boolean enableIgnored)
enableIgnored - the flag
public boolean editCellAt(int row,
int column,
EventObject e)
editCellAt in class JTableprotected boolean isValidCellEditingKey(KeyEvent keyEvent)
if (keyEvent.getKeyCode() == KeyEvent.VK_UNDEFINED) {
return false;
}
else if ((keyEvent.getKeyCode() >= KeyEvent.VK_COMMA && keyEvent.getKeyCode() <= KeyEvent.VK_DIVIDE)
&& ((keyEvent.getModifiers() & KeyEvent.ALT_MASK) != 0 || (keyEvent.getModifiers() & KeyEvent.CTRL_MASK)
!= 0 || (keyEvent.getModifiers() & KeyEvent.META_MASK) != 0)) {
return false;
}
else if ((keyEvent.getKeyCode() < KeyEvent.VK_COMMA || keyEvent.getKeyCode() > KeyEvent.VK_DIVIDE) &&
(keyEvent.getKeyCode() != KeyEvent.VK_BACK_QUOTE && keyEvent.getKeyCode() != KeyEvent.VK_QUOTE &&
keyEvent.getKeyCode() != KeyEvent.VK_SPACE)) {
return false;
}
return true;
keyEvent - the key event
public void clearSelectionPermanently()
public void clearSelection()
clearSelection in class JTable
public void changeSelection(int rowIndex,
int columnIndex,
boolean toggle,
boolean extend)
TableAdaptertoggle and
extend. Most changes to the selection that are the result of keyboard or mouse events received by
the UI are channeled through this method so that the behavior may be overridden by a subclass. Some UIs may need
more functionality than this method provides, such as when manipulating the lead for discontiguous selection, and
may not call into this method for some selection changes.
This implementation uses the following conventions: toggle: false,
extend: false. Clear the previous selection and ensure the new cell is selected. toggle: false, extend: true. Extend the previous selection from the
anchor to the specified cell, clearing all other selections. toggle: true,
extend: false. If the specified cell is selected, deselect it. If it is not selected,
select it. toggle: true, extend: true. Apply the selection state
of the anchor to all cells between it and the specified cell.
changeSelection in interface TableAdapterchangeSelection in class JTablerowIndex - affects the selection at rowcolumnIndex - affects the selection at columntoggle - see description aboveextend - if true, extend the current selectionpublic void addColumn(TableColumn column)
TableColumnChooser.hideColumn(javax.swing.JTable, int) method.
addColumn in class JTablecolumn - the TableColumn to be added.
public void adjustSelectionWhenColumnMoved(int column,
int targetColumn)
column - the column indextargetColumn - the target column index.
public void releaseRendererComponent(TableCellRenderer renderer,
int row,
int column,
Component component)
public Component prepareRenderer(TableCellRenderer renderer,
int row,
int column)
prepareRenderer in class JTablepublic Color getSelectionBackground()
getSelectionBackground in class JTablepublic boolean isColumnAutoResizable()
public void setColumnAutoResizable(boolean resizable)
resizable - true to make column auto-resizable.public boolean isColumnResizable()
public void setColumnResizable(boolean resizable)
resizable - true to make column resizable.public boolean isRowResizable()
public void setRowResizable(boolean resizable)
resizable - true to make row resizable.public void selectAll()
selectAll in class JTablepublic String getToolTipText(MouseEvent event)
getToolTipText in class JTablepublic boolean isTablePrinting()
public void setTablePrinting(boolean tablePrinting)
tablePrinting - true to indicate the table is being printed.public boolean isVariousRowHeights()
isRowAutoResizes() is true.public void setVariousRowHeights(boolean variousRowHeights)
variousRowHeights - true or falsepublic TransferHandler getTransferHandler()
getTransferHandler in class JComponentpublic boolean isSelectInsertedRows()
public void setSelectInsertedRows(boolean selectInsertedRows)
selectInsertedRows - true or false.public boolean isClearSelectionOnTableDataChanges()
public void setClearSelectionOnTableDataChanges(boolean clearSelectionOnTableDataChanges)
clearSelectionOnTableDataChanges - true to clear selection when table data changed event is fired.public void valueChanged(ListSelectionEvent e)
valueChanged in interface ListSelectionListenervalueChanged in class JTablepublic void setClickCountToStart(int count)
count - an int specifying the number of clicks needed to start editinggetClickCountToStart()public int getClickCountToStart()
public Color getGridColor(int row)
row - the row index.
public Color getVerticalGridColor(int column)
column - the column index.
public TableColumnWidthKeeper getTableColumnWidthKeeper()
public void setTableColumnWidthKeeper(TableColumnWidthKeeper tableColumnWidthKeeper)
public void setPreferredSize(Dimension preferredSize)
setPreferredSize in class JComponentpublic boolean isAutoStartCellEditing()
public void setAutoStartCellEditing(boolean autoStartCellEditing)
autoStartCellEditing - true or false.protected boolean isAutoStartCellEditingKey(KeyStroke ks)
isAutoStartCellEditing() is true.
ks - the key stroke
public void addNotify()
addNotify in class JTablepublic void removeNotify()
removeNotify in class JTablepublic void removeEditor()
removeEditor in class JTablepublic boolean isAutoSelectTextWhenStartsEditing()
getTextComponentForEditorComponent(java.awt.Component) to return the
JTextComponent that you would like the text to be selected.
Default is true.
public void setAutoSelectTextWhenStartsEditing(boolean autoSelectTextWhenStartsEditing)
getTextComponentForEditorComponent(java.awt.Component) to return the
JTextComponent that you would like the text to be selected.
Default is true.
autoSelectTextWhenStartsEditing - true or false.public int convertRowIndexToView(int modelRowIndex)
convertRowIndexToView in class JTablemodelRowIndex - the model row index.
public int convertRowIndexToModel(int viewRowIndex)
convertRowIndexToModel in class JTableviewRowIndex - the view row index.
public boolean alwaysCalculateCellRect()
public boolean isCellContentVisible()
public void setCellContentVisible(boolean cellContentVisible)
cellContentVisible - true or false.public void configureEnclosingScrollPaneExplicitly()
public void columnAdded(TableColumnModelEvent e)
columnAdded in interface TableColumnModelListenercolumnAdded in class JTablepublic void columnRemoved(TableColumnModelEvent e)
columnRemoved in interface TableColumnModelListenercolumnRemoved in class JTablepublic void columnMoved(TableColumnModelEvent e)
columnMoved in interface TableColumnModelListenercolumnMoved in class JTablepublic void setEnabled(boolean enabled)
setEnabled in class JComponentpublic int getEditorAutoCompletionMode()
public void setEditorAutoCompletionMode(int editorAutoCompletionMode)
editorAutoCompletionMode - the editor auto-completion mode.
protected boolean isCellFocused(int rowIndex,
int columnIndex)
rowIndex - the row index of the cellcolumnIndex - the column index of the cell
|
JIDE 2.9.5 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||