|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
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.sciapp.table.AdvancedJTable
public class AdvancedJTable
AdvancedJTable is a sublass of JTable that makes full use of classes contained in this library, so as to add extra functionality to the JTable Swing component.
The most important features that were added are:
1) There is the option to add a dummy column to the table header with no data underneath,
for decorative purposes. This option is available if the table is enclosed by
an AdvancedJScrollPane, in which case, it can be controlled with setShowDummyColumn
.
2) Define default editors and renderers to those in the com.sciapp.editors and com.sciapp.renderers respectively
3) Autoresize table columns upon double-clicking on a table column border. (see TableAssistant
)
4) Display a popup through which the columns of the table can be dynamically added/removed. (see TableAssistant
)
5) Use a table header whose columns cannot be reordered with right mouse button clicks. (see AdvancedTableHeader
)
6) Correctly handle selection changes when the tabular data are restructured. (see TableReorder
)
7) Programmatically alter the table columns displayed and their widths. (see setTableState(java.lang.String)
)
8) Ability to merge and split cells. (see SpanModel
)
9) Display a row header. (see JTableRowHeader
)
10) Use Styles for easy cell rendering. (see StyleModel
)
11) Make the first column of the table not movable. (see setFirstColumnFixed(boolean)
)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JTable |
---|
JTable.AccessibleJTable |
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.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected TableCellResizer |
cellResizer
object that adds cell-resizing functionality to a JTable |
static int |
COMMIT_EDIT
an edit mode committing edited values when the model changes |
static int |
CONTINUE_EDIT
an edit mode continuing editing when the model changes |
static int |
DISCARD_EDIT
an edit mode discarding edited values when the model changes |
protected int |
editMode
the edit mode that defines the behaviour of the table when its model changes |
protected boolean |
isFirstColumnFixed
boolean flag to indicate whether the first column of the table is fixed. |
protected boolean |
nonContiguousCellSelection
flag indicating whether non-contiguous cell selection is enabled |
protected NonContiguousSelectionModel |
nonContiguousSelectionModel
the non-contiguous selection model |
protected RowHeader |
rowHeader
the table's row header |
protected AdvancedJScrollPane |
scroller
the scrollpane this table is enclosed by |
protected boolean |
showRowHeader
boolean flag to indicate whether the row header should be visible. |
protected SpanDrawer |
spanDrawer
the span drawer. |
protected StyleModel |
styleModel
the style model. |
protected TableAssistant |
tableAssistant
the table assistant |
protected TableReorder |
tableReorder
This is the TableReorder object. |
protected ViewableResizer |
viewableResizer
the viewable resizer. |
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 | |
---|---|
AdvancedJTable()
Constructs a default AdvancedJTable which is initialized with a default data model, a default column model, and a default selection model. |
|
AdvancedJTable(int numRows,
int numColumns)
Constructs an AdvancedJTable with numRows and numColumns of empty cells using the DefaultTableModel. |
|
AdvancedJTable(Object[][] rowData,
Object[] columnNames)
Constructs an AdvancedJTable to display the values in the two dimensional array, rowData, with column names, columnNames. |
|
AdvancedJTable(TableModel dm)
Constructs a JTable which is initialized with dm as the data model, a default column model, and a default selection model. |
|
AdvancedJTable(TableModel dm,
TableColumnModel cm)
Constructs an AdvancedJTable which is initialized with dm as the data model, cm as the column model, and a default selection model. |
|
AdvancedJTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
Constructs an AdvancedJTable which is initialized with dm as the data model, cm as the column model, and sm as the selection model. |
|
AdvancedJTable(Vector rowData,
Vector columnNames)
Constructs an AdvancedJTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. |
Method Summary | |
---|---|
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 |
columnSelectionChanged(ListSelectionEvent e)
Invoked when the selection model of the TableColumnModel
is changed. |
void |
columnWillBeAdded(TableColumnModelEvent e)
Invoked whenever a table column is about to be added. |
void |
columnWillBeMoved(TableColumnModelEvent e)
Invoked whenever a table column is about to be moved. |
void |
columnWillBeRemoved(TableColumnModelEvent e)
Invoked whenever a table column is about to be removed. |
protected void |
configureEnclosingScrollPane()
If this JTable is the viewportView of an enclosing JScrollPane
(the usual situation), configure this ScrollPane by, amongst other things,
installing the table's tableHeader as the columnHeaderView of the scroll pane. |
TableCellResizer |
createDefaultCellResizer()
Creates and returns a cell resizer. |
protected TableColumnModel |
createDefaultColumnModel()
Returns a new instance of DefaultVetoableColumnModel . |
void |
createDefaultColumnsFromModel()
Creates default columns for the table from the data model using the getColumnCount method
defined in the TableModel interface. |
protected void |
createDefaultEditors()
Creates default cell editors for objects, numbers, and boolean values. |
protected NonContiguousSelectionModel |
createDefaultNonContiguousSelectionModel()
Creates and returns a non-contiguous cell selection model |
protected void |
createDefaultRenderers()
Creates default cell renderers for objects, numbers, doubles, dates, booleans, and icons. |
protected RowHeader |
createDefaultRowHeader()
Returns the default row header object which is a ListRowHeader . |
protected StyleModel |
createDefaultStyleModel()
Returns the default style model object which is a DefaultStyleModel . |
protected TableAssistant |
createDefaultTableAssistant()
Creates and returns the table assistant. |
protected JTableHeader |
createDefaultTableHeader()
Returns a new instance of FilterTableHeader . |
protected TableReorder |
createReorder()
Creates and returns a TableReorder that will handle table selection changes. |
protected SpanDrawer |
createSpanDrawer()
Returns a new instance of the span drawer that is used to enable cell spanning. |
protected void |
doEdit(TableModelEvent e,
int newRow)
Discards, commits or continues editing after a model update, according to the table's edit mode. |
protected void |
doEdit(TableModelEvent e,
int newRow,
int editMode)
Discards, commits or continues editing after a model update, according to the edit mode, passed as parameter. |
protected void |
doProcessMouseEvent(MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects. |
protected void |
doProcessMouseMotionEvent(MouseEvent e)
Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED. |
boolean |
editCellAt(int row,
int column,
EventObject e)
Programmatically starts editing the cell at row and
column , if the cell is editable. |
void |
editingStopped(ChangeEvent e)
Invoked when editing is finished. |
TableCellResizer |
getCellResizer()
Returns the cell resizer associated with this table. |
Class |
getColumnClass(int column)
Returns the type of the column appearing in the view at column position column . |
String |
getColumnName(int column)
Returns the name of the column appearing in the view at column position column . |
int |
getEditingRow()
This method has been overriden in order to take into account the presence of the span model. |
int |
getEditMode()
Determines the behaviour of the table when it is being edited and its model changes. |
boolean |
getNonContiguousCellSelection()
Determines whether non-contiguous cell selection is enabled. |
NonContiguousSelectionModel |
getNonContiguousSelectionModel()
Returns the non-contiguous cell selection model that is associated with this table. |
int |
getRealEditingRow()
Returns the index of the editing row. |
RowHeader |
getRowHeader()
Returns the RowHeader used by this JTable. |
JScrollPane |
getScrollPane()
Utility method that returns the scrollpane this table is enclosed by. |
boolean |
getShowDummyColumn()
Determines whether the table is set to show the dummy column. |
boolean |
getShowRowHeader()
Determines whether the row header should be displayed. |
SpanDrawer |
getSpanDrawer()
Returns the span drawer that is used to enable cell spanning. |
StyleModel |
getStyleModel()
Returns the style model used. |
TableAssistant |
getTableAssistant()
Returns the table assistant instance associated with this table. |
TableReorder |
getTableReorder()
Returns the TableReorder that will handle table selection changes. |
String |
getTableState()
Returns a string showing which columns are shown and their corresponding widths. |
Point |
getToolTipLocation(MouseEvent event)
Returns the tooltip location in this component's coordinate system. |
String |
getToolTipText(MouseEvent event)
Overrides JComponent 's getToolTipText
method in order to allow the renderer's tips to be used
if it has text set. |
Object |
getValueAt(int row,
int column)
Returns the cell value at row and column . |
ViewableResizer |
getViewableResizer()
Retrieves the object that paints cells with their contents resized to their viewable dimensions. |
protected boolean |
handleEvent(MouseEvent e,
Component comp)
Handles a mouse event on the table. |
protected void |
initializeLocalVars()
Initializes table properties to their default values. |
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 cell at the specified position is selected. |
boolean |
isDummyColumn(int column)
Determines if the supplied column is the last dummy column. |
boolean |
isFirstColumnFixed()
Determines whether the first column of the table can be removed or reordered. |
Component |
prepareEditor(TableCellEditor editor,
int row,
int column)
Prepares the editor by querying the data model for the value and selection state of the cell at row , column . |
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 . |
protected void |
processMouseEvent(MouseEvent e)
This method is overriden so that the mouse event is appropriately converted due to the presence of fixed/locked columns/rows. |
protected void |
processMouseMotionEvent(MouseEvent e)
This method is overriden so that the mouse event is appropriately converted due to the presence of fixed/locked columns/rows. |
void |
removeEditor()
Discards the editor object and frees the real estate it used for cell rendering. |
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 |
setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized. |
void |
setCellResizer(TableCellResizer cellResizer)
Assigns a cell resizer to this table. |
void |
setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers
for listener notifications from the new column model. |
void |
setEditMode(int editMode)
Determines the behaviour of the table when it is being edited and its model changes. |
void |
setEvenColor(Color evenColor)
Utility method to set the color for painting the even rows of the table by looking for an instance of DefaultStyle in the style model's list of styles. |
void |
setFirstColumnFixed(boolean isFirstColumnFixed)
Assigns a boolean flag that is true if the first column of the table can be removed or reordered. |
void |
setModel(TableModel newModel)
Sets the data model for this table to newModel and registers
with it for listener notifications from the new data model. |
void |
setNonContiguousCellSelection(boolean nonContiguousCellSelection)
Determines whether non-contiguous cell selection is enabled. |
void |
setNonContiguousSelectionModel(NonContiguousSelectionModel nonContiguousSelectionModel)
Assigns a non-contiguous cell selection model to this table. |
void |
setOddColor(Color oddColor)
Utility method to set the color for painting the odd rows of the table by looking for an instance of DefaultStyle in the style model's list of styles. |
void |
setRowHeader(RowHeader newRowHeader)
Sets the RowHeader working with this JTable to newRowHeader. |
void |
setShowDummyColumn(boolean showDummyColumn)
Sets this table's showLastColumn flag. |
void |
setShowRowHeader(boolean newShowRowHeader)
Sets whether or not the row header should be displayed. |
void |
setSpanDrawer(SpanDrawer newSpanDrawer)
Sets the span drawer that is used to enable cell spanning. |
void |
setStyleModel(StyleModel styleModel)
Sets a new style model to be used. |
void |
setTableAssistant(TableAssistant tableAssistant)
Assigns the table assistant instance associated with this table. |
void |
setTableHeader(JTableHeader newHeader)
Sets the tableHeader working with this JTable to newHeader . |
void |
setTableReorder(TableReorder newTableReorder)
Assigns a table reorder that will handle table selection changes. |
void |
setTableState(String state)
Set which columns will be shown and their corresponding widths. |
void |
sizeColumnsToFit(int resizingColumn)
Obsolete as of Java 2 platform v1.4. |
void |
tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates
a TableModelEvent . |
void |
updateUI()
Notification from the UIManager that the L&F has changed. |
void |
valueChanged(ListSelectionEvent e)
Invoked when the row selection changes -- repaints to show the new selection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DISCARD_EDIT
public static final int COMMIT_EDIT
public static final int CONTINUE_EDIT
protected int editMode
protected boolean nonContiguousCellSelection
protected transient NonContiguousSelectionModel nonContiguousSelectionModel
protected transient TableCellResizer cellResizer
protected transient TableReorder tableReorder
protected boolean isFirstColumnFixed
protected transient RowHeader rowHeader
protected boolean showRowHeader
protected transient StyleModel styleModel
protected transient SpanDrawer spanDrawer
protected transient ViewableResizer viewableResizer
protected transient AdvancedJScrollPane scroller
protected transient TableAssistant tableAssistant
Constructor Detail |
---|
public AdvancedJTable()
public AdvancedJTable(Object[][] rowData, Object[] columnNames)
rowData[1][5];
All rows must be of the same length as columnNames.
public AdvancedJTable(int numRows, int numColumns)
public AdvancedJTable(Vector rowData, Vector columnNames)
((Vector)rowData.elementAt(1)).elementAt(5);
All rows must be of the same length as columnNames.
public AdvancedJTable(TableModel dm)
public AdvancedJTable(TableModel dm, TableColumnModel cm)
public AdvancedJTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Method Detail |
---|
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
toggle
and extend
. All 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.
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 to include the specified cell.
toggle
: true, extend
: false.
If the specified cell is selected, deselect it. If it is not selected, select it.
toggle
: true, extend
: true.
Leave the selection state as it is, but move the anchor index to the specified location.
changeSelection
in class JTable
rowIndex
- affects the selection at row
columnIndex
- affects the selection at column
toggle
- see description aboveextend
- if true, extend the current selectionpublic void columnSelectionChanged(ListSelectionEvent e)
TableColumnModel
is changed.
Application code will not use these methods explicitly, they are used internally by JTable.
columnSelectionChanged
in interface TableColumnModelListener
columnSelectionChanged
in class JTable
e
- the event receivedTableColumnModelListener
public void columnWillBeAdded(TableColumnModelEvent e) throws ColumnModelVetoException
columnWillBeAdded
in interface VetoableTableColumnModelListener
e
- the event identifying the addition.
ColumnModelVetoException
public void columnWillBeMoved(TableColumnModelEvent e) throws ColumnModelVetoException
columnWillBeMoved
in interface VetoableTableColumnModelListener
e
- the event identifying the move.
ColumnModelVetoException
public void columnWillBeRemoved(TableColumnModelEvent e) throws ColumnModelVetoException
columnWillBeRemoved
in interface VetoableTableColumnModelListener
e
- the event identifying the removal.
ColumnModelVetoException
protected void configureEnclosingScrollPane()
JTable
is the viewportView
of an enclosing JScrollPane
(the usual situation), configure this ScrollPane
by, amongst other things,
installing the table's tableHeader
as the columnHeaderView
of the scroll pane.
When a JTable
is added to a JScrollPane
in the usual way,
using new JScrollPane(myTable)
, addNotify
is
called in the JTable
(when the table is added to the viewport).
JTable
's addNotify
method in turn calls this method,
which is protected so that this default installation procedure can
be overridden by a subclass.
configureEnclosingScrollPane
in class JTable
JTable.addNotify()
public TableCellResizer createDefaultCellResizer()
protected TableColumnModel createDefaultColumnModel()
DefaultVetoableColumnModel
.
Returns the default column model object, which is
a DefaultTableColumnModel
. A subclass can override this
method to return a different column model object.
createDefaultColumnModel
in class JTable
DefaultTableColumnModel
public void createDefaultColumnsFromModel()
getColumnCount
method
defined in the TableModel
interface.
Clears any existing columns before creating the new columns based on information from the model.
createDefaultColumnsFromModel
in class JTable
JTable.getAutoCreateColumnsFromModel()
protected void createDefaultEditors()
createDefaultEditors
in class JTable
DefaultCellEditor
protected NonContiguousSelectionModel createDefaultNonContiguousSelectionModel()
protected void createDefaultRenderers()
createDefaultRenderers
in class JTable
DefaultTableCellRenderer
protected RowHeader createDefaultRowHeader()
ListRowHeader
.
protected StyleModel createDefaultStyleModel()
DefaultStyleModel
.
protected TableAssistant createDefaultTableAssistant()
protected JTableHeader createDefaultTableHeader()
FilterTableHeader
.
Returns the default table header object, which is
a JTableHeader
. A subclass can override this
method to return a different table header object.
createDefaultTableHeader
in class JTable
JTableHeader
protected TableReorder createReorder()
protected SpanDrawer createSpanDrawer()
protected void doEdit(TableModelEvent e, int newRow)
getEditMode
.
e
- the model update event triggering the methodnewRow
- the new row index of the row being editedprotected void doEdit(TableModelEvent e, int newRow, int editMode)
getEditMode
.
e
- the model update event triggering the methodnewRow
- the new row index of the row being editededitMode
- the edit modeprotected void doProcessMouseEvent(MouseEvent e)
e
- the 'converted' mouse eventprotected void doProcessMouseMotionEvent(MouseEvent e)
e
- the 'converted' mouse eventpublic boolean editCellAt(int row, int column, EventObject e)
row
and
column
, if the cell is editable.
To prevent the JTable
from editing a particular table,
column or cell value, return false from the isCellEditable
method in the TableModel
interface.
editCellAt
in class JTable
row
- the row to be editedcolumn
- the column to be editede
- event to pass into shouldSelectCell
;
note that as of Java 2 platform v1.2, the call to
shouldSelectCell
is no longer made
public void editingStopped(ChangeEvent e)
Application code will not use these methods explicitly, they are used internally by JTable.
editingStopped
in interface CellEditorListener
editingStopped
in class JTable
e
- the event receivedCellEditorListener
public TableCellResizer getCellResizer()
public Class getColumnClass(int column)
column
.
getColumnClass
in class JTable
column
- the column in the view being queried
column
in the view where the first column is column 0public String getColumnName(int column)
column
.
getColumnName
in class JTable
column
- the column in the view being queried
column
in the view where the first column is column 0public int getEditingRow()
getRealEditingRow
instead.
Returns the index of the row that contains the cell currently being edited. If nothing is being edited, returns -1.
getEditingRow
in class JTable
JTable.editingColumn
public int getEditMode()
public boolean getNonContiguousCellSelection()
public NonContiguousSelectionModel getNonContiguousSelectionModel()
public int getRealEditingRow()
JTable.editingColumn
public RowHeader getRowHeader()
setRowHeader(com.sciapp.table.RowHeader)
public JScrollPane getScrollPane()
public boolean getShowDummyColumn()
public boolean getShowRowHeader()
public SpanDrawer getSpanDrawer()
public StyleModel getStyleModel()
public TableAssistant getTableAssistant()
public TableReorder getTableReorder()
public String getTableState()
public Point getToolTipLocation(MouseEvent event)
null
is returned, Swing will choose a location.
The default implementation returns null
.
getToolTipLocation
in class JComponent
event
- the MouseEvent
that caused the
ToolTipManager
to show the tooltip
null
public String getToolTipText(MouseEvent event)
JComponent
's getToolTipText
method in order to allow the renderer's tips to be used
if it has text set.
JTable
to properly display
tooltips of its renderers
JTable
must be a registered component with the
ToolTipManager
.
This is done automatically in initializeLocalVars
,
but if at a later point JTable
is told
setToolTipText(null)
it will unregister the table
component, and no tips from renderers will display anymore.
getToolTipText
in class JTable
JComponent.getToolTipText()
public Object getValueAt(int row, int column)
row
and column
.
Note: The column is specified in the table view's display
order, and not in the TableModel
's column
order. This is an important distinction because as the
user rearranges the columns in the table,
the column at a given index in the view will change.
Meanwhile the user's actions never affect the model's
column ordering.
getValueAt
in class JTable
row
- the row whose value is to be queriedcolumn
- the column whose value is to be queried
public ViewableResizer getViewableResizer()
protected boolean handleEvent(MouseEvent e, Component comp)
e
- the mouse event that triggered the methodcomp
- the drawn table cell component
protected void initializeLocalVars()
initializeLocalVars
in class JTable
public boolean isCellEditable(int row, int column)
row
and column
is editable. Otherwise, invoking setValueAt
on the cell
will have no effect.
Note: The column is specified in the table view's display
order, and not in the TableModel
's column
order. This is an important distinction because as the
user rearranges the columns in the table,
the column at a given index in the view will change.
Meanwhile the user's actions never affect the model's
column ordering.
isCellEditable
in class JTable
row
- the row whose value is to be queriedcolumn
- the column whose value is to be queried
JTable.setValueAt(java.lang.Object, int, int)
public boolean isCellSelected(int row, int column)
isCellSelected
in class JTable
row
- the row being queriedcolumn
- the column being queried
(row, column)
is selected,
where the first row and first column are at index 0public boolean isDummyColumn(int column)
column
- the index of the table column
public boolean isFirstColumnFixed()
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.
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 editedpublic Component prepareRenderer(TableCellRenderer renderer, int row, int column)
row
, column
.
Returns the component (may be a Component
or a JComponent
) under the event location.
Note: Throughout the table package, the internal implementations always use this method to prepare renderers so that this default behavior can be safely overridden by a subclass.
prepareRenderer
in class JTable
renderer
- the TableCellRenderer
to preparerow
- 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
Component
under the event locationprotected void processMouseEvent(MouseEvent e)
doProcessMouseEvent
method is then called.
Processes mouse events occurring on this component by
dispatching them to any registered
MouseListener
objects.
This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs:
MouseListener
object is registered
via addMouseListener
.
enableEvents
.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
processMouseEvent
in class Component
e
- the mouse eventMouseEvent
,
MouseListener
,
Component.addMouseListener(java.awt.event.MouseListener)
,
Component.enableEvents(long)
protected void processMouseMotionEvent(MouseEvent e)
doProcessMouseMotionEvent
method is then called.
Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.
processMouseMotionEvent
in class JComponent
e
- the MouseEvent
MouseEvent
public void removeEditor()
removeEditor
in class JTable
public void scrollRectToVisible(Rectangle aRect)
scrollRectToVisible()
message to the
JComponent
's parent. Components that can service
the request, such as JViewport
,
override this method and perform the scrolling.
scrollRectToVisible
in class JComponent
aRect
- the visible Rectangle
JViewport
public void selectAll()
selectAll
in class JTable
public void setAutoResizeMode(int mode)
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_COLUMNSJTable.getAutoResizeMode()
,
JTable.doLayout()
public void setCellResizer(TableCellResizer cellResizer)
cellResizer
- the cell resizerpublic void setColumnModel(TableColumnModel newModel)
newModel
and registers
for listener notifications from the new column model. Also sets
the column model of the JTableHeader
to columnModel
.
setColumnModel
in class JTable
newModel
- the new data source for this tableJTable.getColumnModel()
public void setEditMode(int editMode)
getEditMode
.
editMode
- the edit modepublic void setEvenColor(Color evenColor)
evenColor
- the even row colorpublic void setFirstColumnFixed(boolean isFirstColumnFixed)
isFirstColumnFixed
- a boolean which is true if we are able to remove or reorder the first column.public void setModel(TableModel newModel)
newModel
and registers
with it for listener notifications from the new data model.
setModel
in class JTable
newModel
- the new data source for this tableJTable.getModel()
public void setNonContiguousCellSelection(boolean nonContiguousCellSelection)
nonContiguousCellSelection
- true if non-contiguous cell selection is enabled, false otherwisepublic void setNonContiguousSelectionModel(NonContiguousSelectionModel nonContiguousSelectionModel)
nonContiguousSelectionModel
- the non-contiguous cell selection modelpublic void setOddColor(Color oddColor)
oddColor
- the odd row colorpublic void setRowHeader(RowHeader newRowHeader)
newRowHeader
- the new RowHeadergetRowHeader()
public void setShowDummyColumn(boolean showDummyColumn)
public void setShowRowHeader(boolean newShowRowHeader)
newShowRowHeader
- true if the row header should be visible, false otherwise.public void setSpanDrawer(SpanDrawer newSpanDrawer)
newSpanDrawer
- the associated span drawerpublic void setStyleModel(StyleModel styleModel)
styleModel
- the new style model to assign.public void setTableAssistant(TableAssistant tableAssistant)
tableAssistant
- the table assistant to assignpublic void setTableHeader(JTableHeader newHeader)
tableHeader
working with this JTable
to newHeader
.
It is legal to have a null
tableHeader
.
setTableHeader
in class JTable
newHeader
- new tableHeaderJTable.getTableHeader()
public void setTableReorder(TableReorder newTableReorder)
newTableReorder
- the TableReorder object to assign.public void setTableState(String state)
state
is formatted as follows:
i1:w1,i2:w2,...
where i is the column's model index and w its width.
A column which is removed by calling this method can always be added later
if its model index is supplied. Only columns that are removed via the removeColumn method
of JTable are permanently removed from the table.
state
- a string showing which columns will be shown and their corresponding widths.public void sizeColumnsToFit(int resizingColumn)
doLayout()
method instead.
sizeColumnsToFit
in class JTable
resizingColumn
- the column whose resizing made this adjustment
necessary or -1 if there is no such columnJTable.doLayout()
public 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
.
Note that as of 1.3, this method clears the selection, if any.
tableChanged
in interface TableModelListener
tableChanged
in class JTable
public void updateUI()
UIManager
that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager
.
updateUI
in class JTable
JComponent.updateUI()
public void valueChanged(ListSelectionEvent e)
Application code will not use these methods explicitly, they are used internally by JTable.
valueChanged
in interface ListSelectionListener
valueChanged
in class JTable
e
- the event receivedListSelectionListener
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |