JTablepublic class JTable extends JComponent implements TableColumnModelListener, TableModelListener, CellEditorListener, Scrollable, ListSelectionListener, AccessibleThe JTable is used to display and edit regular two-dimensional tables
of cells.
See How to Use Tables
in The Java Tutorial
for task-oriented documentation and examples of using JTable .
The JTable has many
facilities that make it possible to customize its rendering and editing
but provides defaults for these features so that simple tables can be
set up easily. For example, to set up a table with 10 rows and 10
columns of numbers:
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() { return 10; }
public int getRowCount() { return 10;}
public Object getValueAt(int row, int col) { return new Integer(row*col); }
};
JTable table = new JTable(dataModel);
JScrollPane scrollpane = new JScrollPane(table);
Note that if you wish to use a JTable in a standalone
view (outside of a JScrollPane ) and want the header
displayed, you can get it using {@link #getTableHeader} and
display it separately.
When designing applications that use the JTable it is worth paying
close attention to the data structures that will represent the table's data.
The DefaultTableModel is a model implementation that
uses a Vector of Vector s of Object s to
store the cell values. As well as copying the data from an
application into the DefaultTableModel ,
it is also possible to wrap the data in the methods of the
TableModel interface so that the data can be passed to the
JTable directly, as in the example above. This often results
in more efficient applications because the model is free to choose the
internal representation that best suits the data.
A good rule of thumb for deciding whether to use the AbstractTableModel
or the DefaultTableModel is to use the AbstractTableModel
as the base class for creating subclasses and the DefaultTableModel
when subclassing is not required.
The "TableExample" directory in the demo area of the source distribution
gives a number of complete examples of JTable usage,
covering how the JTable can be used to provide an
editable view of data taken from a database and how to modify
the columns in the display to use specialized renderers and editors.
The JTable uses integers exclusively to refer to both the rows and the columns
of the model that it displays. The JTable simply takes a tabular range of cells
and uses getValueAt(int, int) to retrieve the
values from the model during painting.
By default, columns may be rearranged in the JTable so that the
view's columns appear in a different order to the columns in the model.
This does not affect the implementation of the model at all: when the
columns are reordered, the JTable maintains the new order of the columns
internally and converts its column indices before querying the model.
So, when writing a TableModel , it is not necessary to listen for column
reordering events as the model will be queried in its own coordinate
system regardless of what is happening in the view.
In the examples area there is a demonstration of a sorting algorithm making
use of exactly this technique to interpose yet another coordinate system
where the order of the rows is changed, rather than the order of the columns.
J2SE 5 adds methods to JTable to provide convenient access to some
common printing needs. Simple new {@link #print()} methods allow for quick
and easy addition of printing support to your application. In addition, a new
{@link #getPrintable} method is available for more advanced printing needs.
As for all JComponent classes, you can use
{@link InputMap} and {@link ActionMap} to associate an
{@link Action} object with a {@link KeyStroke} and execute the
action under specified conditions.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see {@link java.beans.XMLEncoder}. |
Fields Summary |
---|
private static final String | uiClassID | public static final int | AUTO_RESIZE_OFFDo not adjust column widths automatically; use a scrollbar. | public static final int | AUTO_RESIZE_NEXT_COLUMNWhen a column is adjusted in the UI, adjust the next column the opposite way. | public static final int | AUTO_RESIZE_SUBSEQUENT_COLUMNSDuring UI adjustment, change subsequent columns to preserve the total width;
this is the default behavior. | public static final int | AUTO_RESIZE_LAST_COLUMNDuring all resize operations, apply adjustments to the last column only. | public static final int | AUTO_RESIZE_ALL_COLUMNSDuring all resize operations, proportionately resize all columns. | protected TableModel | dataModelThe TableModel of the table. | protected TableColumnModel | columnModelThe TableColumnModel of the table. | protected ListSelectionModel | selectionModelThe ListSelectionModel of the table, used to keep track of row selections. | protected JTableHeader | tableHeaderThe TableHeader working with the table. | protected int | rowHeightThe height in pixels of each row in the table. | protected int | rowMarginThe height in pixels of the margin between the cells in each row. | protected Color | gridColorThe color of the grid. | protected boolean | showHorizontalLinesThe table draws horizontal lines between cells if showHorizontalLines is true. | protected boolean | showVerticalLinesThe table draws vertical lines between cells if showVerticalLines is true. | protected int | autoResizeModeDetermines if the table automatically resizes the
width of the table's columns to take up the entire width of the
table, and how it does the resizing. | protected boolean | autoCreateColumnsFromModelThe table will query the TableModel to build the default
set of columns if this is true. | protected Dimension | preferredViewportSizeUsed by the Scrollable interface to determine the initial visible area. | protected boolean | rowSelectionAllowedTrue if row selection is allowed in this table. | protected boolean | cellSelectionEnabledObsolete as of Java 2 platform v1.3. Please use the
rowSelectionAllowed property and the
columnSelectionAllowed property of the
columnModel instead. Or use the
method getCellSelectionEnabled . | protected transient Component | editorCompIf editing, the Component that is handling the editing. | protected transient TableCellEditor | cellEditorThe object that overwrites the screen real estate occupied by the
current cell and allows the user to change its contents. | protected transient int | editingColumnIdentifies the column of the cell being edited. | protected transient int | editingRowIdentifies the row of the cell being edited. | protected transient Hashtable | defaultRenderersByColumnClassA table of objects that display the contents of a cell,
indexed by class as declared in getColumnClass
in the TableModel interface. | protected transient Hashtable | defaultEditorsByColumnClassA table of objects that display and edit the contents of a cell,
indexed by class as declared in getColumnClass
in the TableModel interface. | protected Color | selectionForegroundThe foreground color of selected cells. | protected Color | selectionBackgroundThe background color of selected cells. | private SizeSequence | rowModel | private boolean | dragEnabled | private boolean | surrendersFocusOnKeystroke | private PropertyChangeListener | editorRemover | private boolean | columnSelectionAdjustingThe last value of getValueIsAdjusting from the column selection models
columnSelectionChanged notification. Used to test if a repaint is
needed. | private boolean | rowSelectionAdjustingThe last value of getValueIsAdjusting from the row selection models
valueChanged notification. Used to test if a repaint is needed. | private boolean | isPrintingA flag to indicate whether or not the table is currently being printed.
Used by print() and prepareRenderer() to disable indication of the
selection and focused cell while printing. | private Throwable | printErrorTo communicate errors between threads during printing. | private boolean | isRowHeightSetTrue when setRowHeight(int) has been invoked. |
Constructors Summary |
---|
public JTable()Constructs a default JTable that is initialized with a default
data model, a default column model, and a default selection
model.
//
// Constructors
//
this(null, null, null);
| public JTable(TableModel dm)Constructs a JTable that is initialized with
dm as the data model, a default column model,
and a default selection model.
this(dm, null, null);
| public 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.
this(dm, cm, null);
| public JTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)Constructs a JTable that is initialized with
dm as the data model, cm as the
column model, and sm as the selection model.
If any of the parameters are null this method
will initialize the table with the corresponding default model.
The autoCreateColumnsFromModel flag is set to false
if cm is non-null, otherwise it is set to true
and the column model is populated with suitable
TableColumns for the columns in dm .
super();
setLayout(null);
setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
JComponent.getManagingFocusForwardTraversalKeys());
setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
JComponent.getManagingFocusBackwardTraversalKeys());
if (cm == null) {
cm = createDefaultColumnModel();
autoCreateColumnsFromModel = true;
}
setColumnModel(cm);
if (sm == null) {
sm = createDefaultSelectionModel();
}
setSelectionModel(sm);
// Set the model last, that way if the autoCreatColumnsFromModel has
// been set above, we will automatically populate an empty columnModel
// with suitable columns for the new model.
if (dm == null) {
dm = createDefaultDataModel();
}
setModel(dm);
initializeLocalVars();
updateUI();
| public JTable(int numRows, int numColumns)Constructs a JTable with numRows
and numColumns of empty cells using
DefaultTableModel . The columns will have
names of the form "A", "B", "C", etc.
this(new DefaultTableModel(numRows, numColumns));
| public JTable(Vector rowData, Vector columnNames)Constructs a JTable to display the values in the
Vector of Vectors , rowData ,
with column names, columnNames . The
Vectors contained in rowData
should contain the values for that row. In other words,
the value of the cell at row 1, column 5 can be obtained
with the following code:
((Vector)rowData.elementAt(1)).elementAt(5);
this(new DefaultTableModel(rowData, columnNames));
| public JTable(Object[] rowData, Object[] columnNames)Constructs a JTable to display the values in the two dimensional array,
rowData , with column names, columnNames .
rowData is an array of rows, so the value of the cell at row 1,
column 5 can be obtained with the following code:
rowData[1][5];
All rows must be of the same length as columnNames .
this(new AbstractTableModel() {
public String getColumnName(int column) { return columnNames[column].toString(); }
public int getRowCount() { return rowData.length; }
public int getColumnCount() { return columnNames.length; }
public Object getValueAt(int row, int col) { return rowData[row][col]; }
public boolean isCellEditable(int row, int column) { return true; }
public void setValueAt(Object value, int row, int col) {
rowData[row][col] = value;
fireTableCellUpdated(row, col);
}
});
|
Methods Summary |
---|
private void | accommodateDelta(int resizingColumnIndex, int delta)
int columnCount = getColumnCount();
int from = resizingColumnIndex;
int to = columnCount;
// Use the mode to determine how to absorb the changes.
switch(autoResizeMode) {
case AUTO_RESIZE_NEXT_COLUMN:
from = from + 1;
to = Math.min(from + 1, columnCount); break;
case AUTO_RESIZE_SUBSEQUENT_COLUMNS:
from = from + 1;
to = columnCount; break;
case AUTO_RESIZE_LAST_COLUMN:
from = columnCount - 1;
to = from + 1; break;
case AUTO_RESIZE_ALL_COLUMNS:
from = 0;
to = columnCount; break;
default:
return;
}
final int start = from;
final int end = to;
final TableColumnModel cm = columnModel;
Resizable3 r = new Resizable3() {
public int getElementCount() { return end-start; }
public int getLowerBoundAt(int i) { return cm.getColumn(i+start).getMinWidth(); }
public int getUpperBoundAt(int i) { return cm.getColumn(i+start).getMaxWidth(); }
public int getMidPointAt(int i) { return cm.getColumn(i+start).getWidth(); }
public void setSizeAt(int s, int i) { cm.getColumn(i+start).setWidth(s); }
};
int totalWidth = 0;
for(int i = from; i < to; i++) {
TableColumn aColumn = columnModel.getColumn(i);
int input = aColumn.getWidth();
totalWidth = totalWidth + input;
}
adjustSizes(totalWidth + delta, r, false);
return;
| public void | addColumn(javax.swing.table.TableColumn aColumn)Appends aColumn to the end of the array of columns held by
this JTable 's column model.
If the column name of aColumn is null ,
sets the column name of aColumn to the name
returned by getModel().getColumnName() .
To add a column to this JTable to display the
modelColumn 'th column of data in the model with a
given width , cellRenderer ,
and cellEditor you can use:
addColumn(new TableColumn(modelColumn, width, cellRenderer, cellEditor));
[Any of the TableColumn constructors can be used
instead of this one.]
The model column number is stored inside the TableColumn
and is used during rendering and editing to locate the appropriates
data values in the model. The model column number does not change
when columns are reordered in the view.
if (aColumn.getHeaderValue() == null) {
int modelColumn = aColumn.getModelIndex();
String columnName = getModel().getColumnName(modelColumn);
aColumn.setHeaderValue(columnName);
}
getColumnModel().addColumn(aColumn);
| public void | addColumnSelectionInterval(int index0, int index1)Adds the columns from index0 to index1 ,
inclusive, to the current selection.
columnModel.getSelectionModel().addSelectionInterval(boundColumn(index0), boundColumn(index1));
| public void | addNotify()Calls the configureEnclosingScrollPane method.
super.addNotify();
configureEnclosingScrollPane();
| public void | addRowSelectionInterval(int index0, int index1)Adds the rows from index0 to index1 , inclusive, to
the current selection.
selectionModel.addSelectionInterval(boundRow(index0), boundRow(index1));
| private void | adjustSizes(long target, javax.swing.JTable$Resizable3 r, boolean inverse)
int N = r.getElementCount();
long totalPreferred = 0;
for(int i = 0; i < N; i++) {
totalPreferred += r.getMidPointAt(i);
}
Resizable2 s;
if ((target < totalPreferred) == !inverse) {
s = new Resizable2() {
public int getElementCount() { return r.getElementCount(); }
public int getLowerBoundAt(int i) { return r.getLowerBoundAt(i); }
public int getUpperBoundAt(int i) { return r.getMidPointAt(i); }
public void setSizeAt(int newSize, int i) { r.setSizeAt(newSize, i); }
};
}
else {
s = new Resizable2() {
public int getElementCount() { return r.getElementCount(); }
public int getLowerBoundAt(int i) { return r.getMidPointAt(i); }
public int getUpperBoundAt(int i) { return r.getUpperBoundAt(i); }
public void setSizeAt(int newSize, int i) { r.setSizeAt(newSize, i); }
};
}
adjustSizes(target, s, !inverse);
| private void | adjustSizes(long target, javax.swing.JTable$Resizable2 r, boolean limitToRange)
long totalLowerBound = 0;
long totalUpperBound = 0;
for(int i = 0; i < r.getElementCount(); i++) {
totalLowerBound += r.getLowerBoundAt(i);
totalUpperBound += r.getUpperBoundAt(i);
}
if (limitToRange) {
target = Math.min(Math.max(totalLowerBound, target), totalUpperBound);
}
for(int i = 0; i < r.getElementCount(); i++) {
int lowerBound = r.getLowerBoundAt(i);
int upperBound = r.getUpperBoundAt(i);
// Check for zero. This happens when the distribution of the delta
// finishes early due to a series of "fixed" entries at the end.
// In this case, lowerBound == upperBound, for all subsequent terms.
int newSize;
if (totalLowerBound == totalUpperBound) {
newSize = lowerBound;
}
else {
double f = (double)(target - totalLowerBound)/(totalUpperBound - totalLowerBound);
newSize = (int)Math.round(lowerBound+f*(upperBound - lowerBound));
// We'd need to round manually in an all integer version.
// size[i] = (int)(((totalUpperBound - target) * lowerBound +
// (target - totalLowerBound) * upperBound)/(totalUpperBound-totalLowerBound));
}
r.setSizeAt(newSize, i);
target -= newSize;
totalLowerBound -= lowerBound;
totalUpperBound -= upperBound;
}
| private int | boundColumn(int col)
if (col< 0 || col >= getColumnCount()) {
throw new IllegalArgumentException("Column index out of range");
}
return col;
| private int | boundRow(int row)
if (row < 0 || row >= getRowCount()) {
throw new IllegalArgumentException("Row index out of range");
}
return row;
| public 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 . 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.
Leave the selection state as it is, but move the anchor index to the specified location.
ListSelectionModel rsm = getSelectionModel();
ListSelectionModel csm = getColumnModel().getSelectionModel();
// Check the selection here rather than in each selection model.
// This is significant in cell selection mode if we are supposed
// to be toggling the selection. In this case it is better to
// ensure that the cell's selection state will indeed be changed.
// If this were done in the code for the selection model it
// might leave a cell in selection state if the row was
// selected but the column was not - as it would toggle them both.
boolean selected = isCellSelected(rowIndex, columnIndex);
changeSelectionModel(csm, columnIndex, toggle, extend, selected);
changeSelectionModel(rsm, rowIndex, toggle, extend, selected);
// Scroll after changing the selection as blit scrolling is immediate,
// so that if we cause the repaint after the scroll we end up painting
// everything!
if (getAutoscrolls()) {
Rectangle cellRect = getCellRect(rowIndex, columnIndex, false);
if (cellRect != null) {
scrollRectToVisible(cellRect);
}
}
| private void | changeSelectionModel(javax.swing.ListSelectionModel sm, int index, boolean toggle, boolean extend, boolean selected)
if (extend) {
if (toggle) {
sm.setAnchorSelectionIndex(index);
}
else {
sm.setSelectionInterval(sm.getAnchorSelectionIndex(), index);
}
}
else {
if (toggle) {
if (selected) {
sm.removeSelectionInterval(index, index);
}
else {
sm.addSelectionInterval(index, index);
}
}
else {
sm.setSelectionInterval(index, index);
}
}
| private void | checkLeadAnchor()Initialize the lead and anchor of the selection model
based on what the table model contains.
TableModel model = getModel();
// Setting the selection model in the constructor will cause
// this to be invoked before the data model has been set.
// Bail in this case.
if (model == null) {
return;
}
int lead = selectionModel.getLeadSelectionIndex();
int count = model.getRowCount();
if (count == 0) {
if (lead != -1) {
// no rows left, set the lead and anchor to -1
selectionModel.setValueIsAdjusting(true);
selectionModel.setAnchorSelectionIndex(-1);
selectionModel.setLeadSelectionIndex(-1);
selectionModel.setValueIsAdjusting(false);
}
} else {
if (lead == -1) {
// set the lead and anchor to the first row
// (without changing the selection)
if (selectionModel.isSelectedIndex(0)) {
selectionModel.addSelectionInterval(0, 0);
} else {
selectionModel.removeSelectionInterval(0, 0);
}
}
}
| public void | clearSelection()Deselects all selected columns and rows.
selectionModel.clearSelection();
columnModel.getSelectionModel().clearSelection();
| public void | columnAdded(javax.swing.event.TableColumnModelEvent e)Invoked when a column is added to the table column model.
Application code will not use these methods explicitly, they
are used internally by JTable.
// If I'm currently editing, then I should stop editing
if (isEditing()) {
removeEditor();
}
resizeAndRepaint();
| public int | columnAtPoint(java.awt.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 x = point.x;
if( !getComponentOrientation().isLeftToRight() ) {
x = getWidth() - x;
}
return getColumnModel().getColumnIndexAtX(x);
| public void | columnMarginChanged(javax.swing.event.ChangeEvent e)Invoked when a column is moved due to a margin change.
If a cell is being edited, then editing is stopped and the cell
is redrawn.
Application code will not use these methods explicitly, they
are used internally by JTable.
if (isEditing()) {
removeEditor();
}
TableColumn resizingColumn = getResizingColumn();
// Need to do this here, before the parent's
// layout manager calls getPreferredSize().
if (resizingColumn != null && autoResizeMode == AUTO_RESIZE_OFF) {
resizingColumn.setPreferredWidth(resizingColumn.getWidth());
}
resizeAndRepaint();
| public void | columnMoved(javax.swing.event.TableColumnModelEvent e)Invoked when a column is repositioned. If a cell is being
edited, then editing is stopped and the cell is redrawn.
Application code will not use these methods explicitly, they
are used internally by JTable.
// If I'm currently editing, then I should stop editing
if (isEditing()) {
removeEditor();
}
repaint();
| public void | columnRemoved(javax.swing.event.TableColumnModelEvent e)Invoked when a column is removed from the table column model.
Application code will not use these methods explicitly, they
are used internally by JTable.
// If I'm currently editing, then I should stop editing
if (isEditing()) {
removeEditor();
}
resizeAndRepaint();
| public void | columnSelectionChanged(javax.swing.event.ListSelectionEvent e)Invoked when the selection model of the TableColumnModel
is changed.
Application code will not use these methods explicitly, they
are used internally by JTable.
boolean isAdjusting = e.getValueIsAdjusting();
if (columnSelectionAdjusting && !isAdjusting) {
// The assumption is that when the model is no longer adjusting
// we will have already gotten all the changes, and therefore
// don't need to do an additional paint.
columnSelectionAdjusting = false;
return;
}
columnSelectionAdjusting = isAdjusting;
// The getCellRect() call will fail unless there is at least one row.
if (getRowCount() <= 0 || getColumnCount() <= 0) {
return;
}
int firstIndex = limit(e.getFirstIndex(), 0, getColumnCount()-1);
int lastIndex = limit(e.getLastIndex(), 0, getColumnCount()-1);
int minRow = 0;
int maxRow = getRowCount() - 1;
if (getRowSelectionAllowed()) {
minRow = selectionModel.getMinSelectionIndex();
maxRow = selectionModel.getMaxSelectionIndex();
int leadRow = selectionModel.getLeadSelectionIndex();
if (minRow == -1 || maxRow == -1) {
if (leadRow == -1) {
// nothing to repaint, return
return;
}
// only thing to repaint is the lead
minRow = maxRow = leadRow;
} else {
// We need to consider more than just the range between
// the min and max selected index. The lead row, which could
// be outside this range, should be considered also.
if (leadRow != -1) {
minRow = Math.min(minRow, leadRow);
maxRow = Math.max(maxRow, leadRow);
}
}
}
Rectangle firstColumnRect = getCellRect(minRow, firstIndex, false);
Rectangle lastColumnRect = getCellRect(maxRow, lastIndex, false);
Rectangle dirtyRegion = firstColumnRect.union(lastColumnRect);
repaint(dirtyRegion);
| void | compWriteObjectNotify()
super.compWriteObjectNotify();
// If ToolTipText != null, then the tooltip has already been
// unregistered by JComponent.compWriteObjectNotify()
if (getToolTipText() == null) {
ToolTipManager.sharedInstance().unregisterComponent(this);
}
| 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.
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.
Container p = getParent();
if (p instanceof JViewport) {
Container gp = p.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
// Make certain we are the viewPort's view and not, for
// example, the rowHeaderView of the scrollPane -
// an implementor of fixed columns might do this.
JViewport viewport = scrollPane.getViewport();
if (viewport == null || viewport.getView() != this) {
return;
}
scrollPane.setColumnHeaderView(getTableHeader());
// scrollPane.getViewport().setBackingStoreEnabled(true);
Border border = scrollPane.getBorder();
if (border == null || border instanceof UIResource) {
scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder"));
}
}
}
| public 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. Returns the index of the corresponding
column in the model. If viewColumnIndex
is less than zero, returns viewColumnIndex .
if (viewColumnIndex < 0) {
return viewColumnIndex;
}
return getColumnModel().getColumn(viewColumnIndex).getModelIndex();
| public 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. Returns the index of the
corresponding column in the view; returns -1 if this column is not
being displayed. If modelColumnIndex is less than zero,
returns modelColumnIndex .
if (modelColumnIndex < 0) {
return modelColumnIndex;
}
TableColumnModel cm = getColumnModel();
for (int column = 0; column < getColumnCount(); column++) {
if (cm.getColumn(column).getModelIndex() == modelColumnIndex) {
return column;
}
}
return -1;
| protected javax.swing.table.TableColumnModel | createDefaultColumnModel()Returns the default column model object, which is
a DefaultTableColumnModel . A subclass can override this
method to return a different column model object.
return new DefaultTableColumnModel();
| public void | createDefaultColumnsFromModel()Creates default columns for the table from
the data model using the getColumnCount method
defined in the TableModel interface.
Clears any existing columns before creating the
new columns based on information from the model.
TableModel m = getModel();
if (m != null) {
// Remove any current columns
TableColumnModel cm = getColumnModel();
while (cm.getColumnCount() > 0) {
cm.removeColumn(cm.getColumn(0));
}
// Create new columns from the data model info
for (int i = 0; i < m.getColumnCount(); i++) {
TableColumn newColumn = new TableColumn(i);
addColumn(newColumn);
}
}
| protected javax.swing.table.TableModel | createDefaultDataModel()Returns the default table model object, which is
a DefaultTableModel . A subclass can override this
method to return a different table model object.
return new DefaultTableModel();
| protected void | createDefaultEditors()Creates default cell editors for objects, numbers, and boolean values.
defaultEditorsByColumnClass = new UIDefaults();
// Objects
setLazyEditor(Object.class, "javax.swing.JTable$GenericEditor");
// Numbers
setLazyEditor(Number.class, "javax.swing.JTable$NumberEditor");
// Booleans
setLazyEditor(Boolean.class, "javax.swing.JTable$BooleanEditor");
| protected void | createDefaultRenderers()Creates default cell renderers for objects, numbers, doubles, dates,
booleans, and icons.
defaultRenderersByColumnClass = new UIDefaults();
// Objects
setLazyRenderer(Object.class, "javax.swing.table.DefaultTableCellRenderer$UIResource");
// Numbers
setLazyRenderer(Number.class, "javax.swing.JTable$NumberRenderer");
// Doubles and Floats
setLazyRenderer(Float.class, "javax.swing.JTable$DoubleRenderer");
setLazyRenderer(Double.class, "javax.swing.JTable$DoubleRenderer");
// Dates
setLazyRenderer(Date.class, "javax.swing.JTable$DateRenderer");
// Icons and ImageIcons
setLazyRenderer(Icon.class, "javax.swing.JTable$IconRenderer");
setLazyRenderer(ImageIcon.class, "javax.swing.JTable$IconRenderer");
// Booleans
setLazyRenderer(Boolean.class, "javax.swing.JTable$BooleanRenderer");
| protected javax.swing.ListSelectionModel | createDefaultSelectionModel()Returns the default selection model object, which is
a DefaultListSelectionModel . A subclass can override this
method to return a different selection model object.
return new DefaultListSelectionModel();
| protected javax.swing.table.JTableHeader | createDefaultTableHeader()Returns the default table header object, which is
a JTableHeader . A subclass can override this
method to return a different table header object.
return new JTableHeader(columnModel);
| public static javax.swing.JScrollPane | createScrollPaneForTable(javax.swing.JTable aTable)Equivalent to new JScrollPane(aTable) .
return new JScrollPane(aTable);
| public void | doLayout()Causes this table to lay out its rows and columns. Overridden so
that columns can be resized to accomodate a change in the size of
a containing parent.
Resizes one or more of the columns in the table
so that the total width of all of this JTable 's
columns is equal to the width of the table.
Before the layout begins the method gets the
resizingColumn of the tableHeader .
When the method is called as a result of the resizing of an enclosing window,
the resizingColumn is null . This means that resizing
has taken place "outside" the JTable and the change -
or "delta" - should be distributed to all of the columns regardless
of this JTable 's automatic resize mode.
If the resizingColumn is not null , it is one of
the columns in the table that has changed size rather than
the table itself. In this case the auto-resize modes govern
the way the extra (or deficit) space is distributed
amongst the available columns.
The modes are:
- AUTO_RESIZE_OFF: Don't automatically adjust the column's
widths at all. Use a horizontal scrollbar to accomodate the
columns when their sum exceeds the width of the
Viewport . If the JTable is not
enclosed in a JScrollPane this may
leave parts of the table invisible.
- AUTO_RESIZE_NEXT_COLUMN: Use just the column after the
resizing column. This results in the "boundary" or divider
between adjacent cells being independently adjustable.
- AUTO_RESIZE_SUBSEQUENT_COLUMNS: Use all columns after the
one being adjusted to absorb the changes. This is the
default behavior.
- AUTO_RESIZE_LAST_COLUMN: Automatically adjust the
size of the last column only. If the bounds of the last column
prevent the desired size from being allocated, set the
width of the last column to the appropriate limit and make
no further adjustments.
- AUTO_RESIZE_ALL_COLUMNS: Spread the delta amongst all the columns
in the
JTable , including the one that is being
adjusted.
Note: When a JTable makes adjustments
to the widths of the columns it respects their minimum and
maximum values absolutely. It is therefore possible that,
even after this method is called, the total width of the columns
is still not equal to the width of the table. When this happens
the JTable does not put itself
in AUTO_RESIZE_OFF mode to bring up a scroll bar, or break other
commitments of its current auto-resize mode -- instead it
allows its bounds to be set larger (or smaller) than the total of the
column minimum or maximum, meaning, either that there
will not be enough room to display all of the columns, or that the
columns will not fill the JTable 's bounds.
These respectively, result in the clipping of some columns
or an area being painted in the JTable 's
background color during painting.
The mechanism for distributing the delta amongst the available
columns is provided in a private method in the JTable
class:
adjustSizes(long targetSize, final Resizable3 r, boolean inverse)
an explanation of which is provided in the following section.
Resizable3 is a private
interface that allows any data structure containing a collection
of elements with a size, preferred size, maximum size and minimum size
to have its elements manipulated by the algorithm.
Distributing the delta
Overview
Call "DELTA" the difference between the target size and the
sum of the preferred sizes of the elements in r. The individual
sizes are calculated by taking the original preferred
sizes and adding a share of the DELTA - that share being based on
how far each preferred size is from its limiting bound (minimum or
maximum).
Definition
Call the individual constraints min[i], max[i], and pref[i].
Call their respective sums: MIN, MAX, and PREF.
Each new size will be calculated using:
size[i] = pref[i] + delta[i]
where each individual delta[i] is calculated according to:
If (DELTA < 0) we are in shrink mode where:
DELTA
delta[i] = ------------ * (pref[i] - min[i])
(PREF - MIN)
If (DELTA > 0) we are in expand mode where:
DELTA
delta[i] = ------------ * (max[i] - pref[i])
(MAX - PREF)
The overall effect is that the total size moves that same percentage,
k, towards the total minimum or maximum and that percentage guarantees
accomodation of the required space, DELTA.
Details
Naive evaluation of the formulae presented here would be subject to
the aggregated rounding errors caused by doing this operation in finite
precision (using ints). To deal with this, the multiplying factor above,
is constantly recalculated and this takes account of the rounding
errors in the previous iterations. The result is an algorithm that
produces a set of integers whose values exactly sum to the supplied
targetSize , and does so by spreading the rounding
errors evenly over the given elements.
When the MAX and MIN bounds are hit
When targetSize is outside the [MIN, MAX] range,
the algorithm sets all sizes to their appropriate limiting value
(maximum or minimum).
TableColumn resizingColumn = getResizingColumn();
if (resizingColumn == null) {
setWidthsFromPreferredWidths(false);
}
else {
// JTable behaves like a layout manger - but one in which the
// user can come along and dictate how big one of the children
// (columns) is supposed to be.
// A column has been resized and JTable may need to distribute
// any overall delta to other columns, according to the resize mode.
int columnIndex = viewIndexForColumn(resizingColumn);
int delta = getWidth() - getColumnModel().getTotalColumnWidth();
accommodateDelta(columnIndex, delta);
delta = getWidth() - getColumnModel().getTotalColumnWidth();
// If the delta cannot be completely accomodated, then the
// resizing column will have to take any remainder. This means
// that the column is not being allowed to take the requested
// width. This happens under many circumstances: For example,
// AUTO_RESIZE_NEXT_COLUMN specifies that any delta be distributed
// to the column after the resizing column. If one were to attempt
// to resize the last column of the table, there would be no
// columns after it, and hence nowhere to distribute the delta.
// It would then be given entirely back to the resizing column,
// preventing it from changing size.
if (delta != 0) {
resizingColumn.setWidth(resizingColumn.getWidth() + delta);
}
// At this point the JTable has to work out what preferred sizes
// would have resulted in the layout the user has chosen.
// Thereafter, during window resizing etc. it has to work off
// the preferred sizes as usual - the idea being that, whatever
// the user does, everything stays in synch and things don't jump
// around.
setWidthsFromPreferredWidths(true);
}
super.doLayout();
| public 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.
Note that this is a convenience method for
editCellAt(int, int, null) .
return editCellAt(row, column, null);
| public boolean | editCellAt(int row, int column, java.util.EventObject e)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.
To prevent the JTable from
editing a particular table, column or cell value, return false from
the isCellEditable method in the TableModel
interface.
if (cellEditor != null && !cellEditor.stopCellEditing()) {
return false;
}
if (row < 0 || row >= getRowCount() ||
column < 0 || column >= getColumnCount()) {
return false;
}
if (!isCellEditable(row, column))
return false;
if (editorRemover == null) {
KeyboardFocusManager fm =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
editorRemover = new CellEditorRemover(fm);
fm.addPropertyChangeListener("permanentFocusOwner", editorRemover);
}
TableCellEditor editor = getCellEditor(row, column);
if (editor != null && editor.isCellEditable(e)) {
editorComp = prepareEditor(editor, row, column);
if (editorComp == null) {
removeEditor();
return false;
}
editorComp.setBounds(getCellRect(row, column, false));
add(editorComp);
editorComp.validate();
setCellEditor(editor);
setEditingRow(row);
setEditingColumn(column);
editor.addCellEditorListener(this);
return true;
}
return false;
| public void | editingCanceled(javax.swing.event.ChangeEvent e)Invoked when editing is canceled. The editor object is discarded
and the cell is rendered once again.
Application code will not use these methods explicitly, they
are used internally by JTable.
removeEditor();
| public void | editingStopped(javax.swing.event.ChangeEvent e)Invoked when editing is finished. The changes are saved and the
editor is discarded.
Application code will not use these methods explicitly, they
are used internally by JTable.
// Take in the new value
TableCellEditor editor = getCellEditor();
if (editor != null) {
Object value = editor.getCellEditorValue();
setValueAt(value, editingRow, editingColumn);
removeEditor();
}
| public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this JTable.
For tables, the AccessibleContext takes the form of an
AccessibleJTable.
A new AccessibleJTable instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleJTable();
}
return accessibleContext;
| public boolean | getAutoCreateColumnsFromModel()Determines whether the table will create default columns from the model.
If true, setModel will clear any existing columns and
create new columns from the new model. Also, if the event in
the tableChanged notification specifies that the
entire table changed, then the columns will be rebuilt.
The default is true.
return autoCreateColumnsFromModel;
| public int | getAutoResizeMode()Returns the auto resize mode of the table. The default mode
is AUTO_RESIZE_SUBSEQUENT_COLUMNS.
return autoResizeMode;
| public javax.swing.table.TableCellEditor | getCellEditor()Returns the cell editor.
return cellEditor;
| public javax.swing.table.TableCellEditor | getCellEditor(int row, int column)Returns an appropriate editor for the cell specified by
row and column . If the
TableColumn for this column has a non-null editor,
returns that. If not, finds the class of the data in this
column (using getColumnClass )
and returns the default editor for this type of data.
Note:
Throughout the table package, the internal implementations always
use this method to provide editors so that this default behavior
can be safely overridden by a subclass.
TableColumn tableColumn = getColumnModel().getColumn(column);
TableCellEditor editor = tableColumn.getCellEditor();
if (editor == null) {
editor = getDefaultEditor(getColumnClass(column));
}
return editor;
| public java.awt.Rectangle | getCellRect(int row, int column, boolean includeSpacing)Returns a rectangle for the cell that lies at the intersection of
row and column .
If includeSpacing is true then the value returned
has the full height and width of the row and column
specified. If it is false, the returned rectangle is inset by the
intercell spacing to return the true bounds of the rendering or
editing component as it will be set during rendering.
If the column index is valid but the row index is less
than zero the method returns a rectangle with the
y and height values set appropriately
and the x and width values both set
to zero. In general, when either the row or column indices indicate a
cell outside the appropriate range, the method returns a rectangle
depicting the closest edge of the closest cell that is within
the table's range. When both row and column indices are out
of range the returned rectangle covers the closest
point of the closest cell.
In all cases, calculations that use this method to calculate
results along one axis will not fail because of anomalies in
calculations along the other axis. When the cell is not valid
the includeSpacing parameter is ignored.
Rectangle r = new Rectangle();
boolean valid = true;
if (row < 0) {
// y = height = 0;
valid = false;
}
else if (row >= getRowCount()) {
r.y = getHeight();
valid = false;
}
else {
r.height = getRowHeight(row);
r.y = (rowModel == null) ? row * r.height : rowModel.getPosition(row);
}
if (column < 0) {
if( !getComponentOrientation().isLeftToRight() ) {
r.x = getWidth();
}
// otherwise, x = width = 0;
valid = false;
}
else if (column >= getColumnCount()) {
if( getComponentOrientation().isLeftToRight() ) {
r.x = getWidth();
}
// otherwise, x = width = 0;
valid = false;
}
else {
TableColumnModel cm = getColumnModel();
if( getComponentOrientation().isLeftToRight() ) {
for(int i = 0; i < column; i++) {
r.x += cm.getColumn(i).getWidth();
}
} else {
for(int i = cm.getColumnCount()-1; i > column; i--) {
r.x += cm.getColumn(i).getWidth();
}
}
r.width = cm.getColumn(column).getWidth();
}
if (valid && !includeSpacing) {
int rm = getRowMargin();
int cm = getColumnModel().getColumnMargin();
// This is not the same as grow(), it rounds differently.
r.setBounds(r.x + cm/2, r.y + rm/2, r.width - cm, r.height - rm);
}
return r;
| public javax.swing.table.TableCellRenderer | getCellRenderer(int row, int column)Returns an appropriate renderer for the cell specified by this row and
column. If the TableColumn for this column has a non-null
renderer, returns that. If not, finds the class of the data in
this column (using getColumnClass )
and returns the default renderer for this type of data.
Note:
Throughout the table package, the internal implementations always
use this method to provide renderers so that this default behavior
can be safely overridden by a subclass.
TableColumn tableColumn = getColumnModel().getColumn(column);
TableCellRenderer renderer = tableColumn.getCellRenderer();
if (renderer == null) {
renderer = getDefaultRenderer(getColumnClass(column));
}
return renderer;
| public boolean | getCellSelectionEnabled()Returns true if both row and column selection models are enabled.
Equivalent to getRowSelectionAllowed() &&
getColumnSelectionAllowed() .
return getRowSelectionAllowed() && getColumnSelectionAllowed();
| public javax.swing.table.TableColumn | getColumn(java.lang.Object identifier)Returns the TableColumn object for the column in the table
whose identifier is equal to identifier , when compared using
equals .
TableColumnModel cm = getColumnModel();
int columnIndex = cm.getColumnIndex(identifier);
return cm.getColumn(columnIndex);
| public java.lang.Class | getColumnClass(int column)Returns the type of the column appearing in the view at
column position column .
return getModel().getColumnClass(convertColumnIndexToModel(column));
| public int | getColumnCount()Returns the number of columns in the column model. Note that this may
be different from the number of columns in the table model.
return getColumnModel().getColumnCount();
| public javax.swing.table.TableColumnModel | getColumnModel()Returns the TableColumnModel that contains all column information
of this table.
return columnModel;
| public java.lang.String | getColumnName(int column)Returns the name of the column appearing in the view at
column position column .
return getModel().getColumnName(convertColumnIndexToModel(column));
| public boolean | getColumnSelectionAllowed()Returns true if columns can be selected.
return columnModel.getColumnSelectionAllowed();
| public javax.swing.table.TableCellEditor | getDefaultEditor(java.lang.Class columnClass)Returns the editor to be used when no editor has been set in
a TableColumn . During the editing of cells the editor is fetched from
a Hashtable of entries according to the class of the cells in the column. If
there is no entry for this columnClass the method returns
the entry for the most specific superclass. The JTable installs entries
for Object , Number , and Boolean , all of which can be modified
or replaced.
if (columnClass == null) {
return null;
}
else {
Object editor = defaultEditorsByColumnClass.get(columnClass);
if (editor != null) {
return (TableCellEditor)editor;
}
else {
return getDefaultEditor(columnClass.getSuperclass());
}
}
| public javax.swing.table.TableCellRenderer | getDefaultRenderer(java.lang.Class columnClass)Returns the cell renderer to be used when no renderer has been set in
a TableColumn . During the rendering of cells the renderer is fetched from
a Hashtable of entries according to the class of the cells in the column. If
there is no entry for this columnClass the method returns
the entry for the most specific superclass. The JTable installs entries
for Object , Number , and Boolean , all of which can be modified
or replaced.
if (columnClass == null) {
return null;
}
else {
Object renderer = defaultRenderersByColumnClass.get(columnClass);
if (renderer != null) {
return (TableCellRenderer)renderer;
}
else {
return getDefaultRenderer(columnClass.getSuperclass());
}
}
| public boolean | getDragEnabled()Gets the value of the dragEnabled property.
return dragEnabled;
| public int | getEditingColumn()Returns the index of the column that contains the cell currently
being edited. If nothing is being edited, returns -1.
return editingColumn;
| public int | getEditingRow()Returns the index of the row that contains the cell currently
being edited. If nothing is being edited, returns -1.
return editingRow;
| public java.awt.Component | getEditorComponent()Returns the component that is handling the editing session.
If nothing is being edited, returns null.
return editorComp;
| public java.awt.Color | getGridColor()Returns the color used to draw grid lines.
The default color is look and feel dependent.
return gridColor;
| public java.awt.Dimension | getIntercellSpacing()Returns the horizontal and vertical space between cells.
The default spacing is (1, 1), which provides room to draw the grid.
return new Dimension(getColumnModel().getColumnMargin(), rowMargin);
| public javax.swing.table.TableModel | getModel()Returns the TableModel that provides the data displayed by this
JTable .
return dataModel;
| public java.awt.Dimension | getPreferredScrollableViewportSize()Returns the preferred size of the viewport for this table.
return preferredViewportSize;
| public java.awt.print.Printable | getPrintable(javax.swing.JTable$PrintMode printMode, java.text.MessageFormat headerFormat, java.text.MessageFormat footerFormat)Return a Printable for use in printing this JTable.
The Printable can be requested in one of two printing modes.
In both modes, it spreads table rows naturally in sequence across
multiple pages, fitting as many rows as possible per page.
PrintMode.NORMAL specifies that the table be
printed at its current size. In this mode, there may be a need to spread
columns across pages in a similar manner to that of the rows. When the
need arises, columns are distributed in an order consistent with the
table's ComponentOrientation .
PrintMode.FIT_WIDTH specifies that the output be
scaled smaller, if necessary, to fit the table's entire width
(and thereby all columns) on each page. Width and height are scaled
equally, maintaining the aspect ratio of the output.
The Printable heads the portion of table on each page
with the appropriate section from the table's JTableHeader ,
if it has one.
Header and footer text can be added to the output by providing
MessageFormat arguments. The printing code requests
Strings from the formats, providing a single item which may be included
in the formatted string: an Integer representing the current
page number.
You are encouraged to read the documentation for
MessageFormat as some characters, such as single-quote,
are special and need to be escaped.
Here's an example of creating a MessageFormat that can be
used to print "Duke's Table: Page - " and the current page number:
// notice the escaping of the single quote
// notice how the page number is included with "{0}"
MessageFormat format = new MessageFormat("Duke''s Table: Page - {0}");
The Printable constrains what it draws to the printable
area of each page that it prints. Under certain circumstances, it may
find it impossible to fit all of a page's content into that area. In
these cases the output may be clipped, but the implementation
makes an effort to do something reasonable. Here are a few situations
where this is known to occur, and how they may be handled by this
particular implementation:
- In any mode, when the header or footer text is too wide to fit
completely in the printable area -- print as much of the text as
possible starting from the beginning, as determined by the table's
ComponentOrientation .
- In any mode, when a row is too tall to fit in the
printable area -- print the upper-most portion of the row
and paint no lower border on the table.
- In
PrintMode.NORMAL when a column
is too wide to fit in the printable area -- print the center
portion of the column and leave the left and right borders
off the table.
It is entirely valid for this Printable to be wrapped
inside another in order to create complex reports and documents. You may
even request that different pages be rendered into different sized
printable areas. The implementation must be prepared to handle this
(possibly by doing its layout calculations on the fly). However,
providing different heights to each page will likely not work well
with PrintMode.NORMAL when it has to spread columns
across pages.
It is important to note that this Printable prints the
table at its current visual state, using the table's existing renderers.
Before calling this method, you may wish to first modify
the state of the table (such as to change the renderers, cancel editing,
or hide the selection).
You must not, however, modify the table in any way after
this Printable is fetched (invalid modifications include
changes in: size, renderers, or underlying data). The behavior of the
returned Printable is undefined once the table has been
changed.
Here's a simple example that calls this method to fetch a
Printable , shows a cross-platform print dialog, and then
prints the Printable unless the user cancels the dialog:
// prepare the table for printing here first (for example, hide selection)
// wrap in a try/finally so table can be restored even if something fails
try {
// fetch the printable
Printable printable = table.getPrintable(JTable.PrintMode.FIT_WIDTH,
new MessageFormat("My Table"),
new MessageFormat("Page - {0}"));
// fetch a PrinterJob
PrinterJob job = PrinterJob.getPrinterJob();
// set the Printable on the PrinterJob
job.setPrintable(printable);
// create an attribute set to store attributes from the print dialog
PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
// display a print dialog and record whether or not the user cancels it
boolean printAccepted = job.printDialog(attr);
// if the user didn't cancel the dialog
if (printAccepted) {
// do the printing (may need to handle PrinterException)
job.print(attr);
}
} finally {
// restore the original table state here (for example, restore selection)
}
return new TablePrintable(this, printMode, headerFormat, footerFormat);
| private javax.swing.table.TableColumn | getResizingColumn()
return (tableHeader == null) ? null
: tableHeader.getResizingColumn();
| public int | getRowCount()Returns the number of rows in this table's model.
return getModel().getRowCount();
| public int | getRowHeight()Returns the height of a table row, in pixels.
The default row height is 16.0.
return rowHeight;
| public int | getRowHeight(int row)Returns the height, in pixels, of the cells in row .
return (rowModel == null) ? getRowHeight() : rowModel.getSize(row);
| public int | getRowMargin()Gets the amount of empty space, in pixels, between cells. Equivalent to:
getIntercellSpacing().height .
return rowMargin;
| private javax.swing.SizeSequence | getRowModel()
if (rowModel == null) {
rowModel = new SizeSequence(getRowCount(), getRowHeight());
}
return rowModel;
| public boolean | getRowSelectionAllowed()Returns true if rows can be selected.
return rowSelectionAllowed;
| public int | getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)Returns visibleRect.height or
visibleRect.width ,
depending on this table's orientation. Note that as of Swing 1.1.1
(Java 2 v 1.2.2) the value
returned will ensure that the viewport is cleanly aligned on
a row boundary.
if (orientation == SwingConstants.VERTICAL) {
int rh = getRowHeight();
return (rh > 0) ? Math.max(rh, (visibleRect.height / rh) * rh) : visibleRect.height;
}
else {
return visibleRect.width;
}
| public boolean | getScrollableTracksViewportHeight()Returns false to indicate that the height of the viewport does not
determine the height of the table.
return false;
| public boolean | getScrollableTracksViewportWidth()Returns false if autoResizeMode is set to
AUTO_RESIZE_OFF , which indicates that the
width of the viewport does not determine the width
of the table. Otherwise returns true.
return !(autoResizeMode == AUTO_RESIZE_OFF);
| public int | getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)Returns the scroll increment (in pixels) that completely exposes one new
row or column (depending on the orientation).
This method is called each time the user requests a unit scroll.
// PENDING(alan): do something smarter
if (orientation == SwingConstants.HORIZONTAL) {
return 100;
}
return getRowHeight();
| public int | getSelectedColumn()Returns the index of the first selected column,
-1 if no column is selected.
return columnModel.getSelectionModel().getMinSelectionIndex();
| public int | getSelectedColumnCount()Returns the number of selected columns.
return columnModel.getSelectedColumnCount();
| public int[] | getSelectedColumns()Returns the indices of all selected columns.
return columnModel.getSelectedColumns();
| public int | getSelectedRow()Returns the index of the first selected row, -1 if no row is selected.
return selectionModel.getMinSelectionIndex();
| public int | getSelectedRowCount()Returns the number of selected rows.
int iMin = selectionModel.getMinSelectionIndex();
int iMax = selectionModel.getMaxSelectionIndex();
int count = 0;
for(int i = iMin; i <= iMax; i++) {
if (selectionModel.isSelectedIndex(i)) {
count++;
}
}
return count;
| public int[] | getSelectedRows()Returns the indices of all selected rows.
int iMin = selectionModel.getMinSelectionIndex();
int iMax = selectionModel.getMaxSelectionIndex();
if ((iMin == -1) || (iMax == -1)) {
return new int[0];
}
int[] rvTmp = new int[1+ (iMax - iMin)];
int n = 0;
for(int i = iMin; i <= iMax; i++) {
if (selectionModel.isSelectedIndex(i)) {
rvTmp[n++] = i;
}
}
int[] rv = new int[n];
System.arraycopy(rvTmp, 0, rv, 0, n);
return rv;
| public java.awt.Color | getSelectionBackground()Returns the background color for selected cells.
return selectionBackground;
| public java.awt.Color | getSelectionForeground()Returns the foreground color for selected cells.
return selectionForeground;
| public javax.swing.ListSelectionModel | getSelectionModel()Returns the ListSelectionModel that is used to maintain row
selection state.
return selectionModel;
| public boolean | getShowHorizontalLines()Returns true if the table draws horizontal lines between cells, false if it
doesn't. The default is true.
return showHorizontalLines;
| public boolean | getShowVerticalLines()Returns true if the table draws vertical lines between cells, false if it
doesn't. The default is true.
return showVerticalLines;
| public boolean | getSurrendersFocusOnKeystroke()Returns true if the editor should get the focus
when keystrokes cause the editor to be activated
return surrendersFocusOnKeystroke;
| public javax.swing.table.JTableHeader | getTableHeader()Returns the tableHeader used by this JTable .
return tableHeader;
| public java.lang.String | getToolTipText(java.awt.event.MouseEvent event)Overrides JComponent 's getToolTipText
method in order to allow the renderer's tips to be used
if it has text set.
Note: For 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.
String tip = null;
Point p = event.getPoint();
// Locate the renderer under the event location
int hitColumnIndex = columnAtPoint(p);
int hitRowIndex = rowAtPoint(p);
if ((hitColumnIndex != -1) && (hitRowIndex != -1)) {
TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);
// Now have to see if the component is a JComponent before
// getting the tip
if (component instanceof JComponent) {
// Convert the event to the renderer's coordinate system
Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false);
p.translate(-cellRect.x, -cellRect.y);
MouseEvent newEvent = new MouseEvent(component, event.getID(),
event.getWhen(), event.getModifiers(),
p.x, p.y, event.getClickCount(),
event.isPopupTrigger());
tip = ((JComponent)component).getToolTipText(newEvent);
}
}
// No tip from the renderer get our own tip
if (tip == null)
tip = getToolTipText();
return tip;
| public javax.swing.plaf.TableUI | getUI()Returns the L&F object that renders this component.
return (TableUI)ui;
| public java.lang.String | getUIClassID()Returns the suffix used to construct the name of the L&F class used to
render this component.
return uiClassID;
| public java.lang.Object | getValueAt(int row, int column)Returns the cell value at 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.
return getModel().getValueAt(row, convertColumnIndexToModel(column));
| protected void | initializeLocalVars()Initializes table properties to their default values.
setOpaque(true);
createDefaultRenderers();
createDefaultEditors();
setTableHeader(createDefaultTableHeader());
setShowGrid(true);
setAutoResizeMode(AUTO_RESIZE_SUBSEQUENT_COLUMNS);
setRowHeight(16);
isRowHeightSet = false;
setRowMargin(1);
setRowSelectionAllowed(true);
setCellEditor(null);
setEditingColumn(-1);
setEditingRow(-1);
setSurrendersFocusOnKeystroke(false);
setPreferredScrollableViewportSize(new Dimension(450, 400));
// I'm registered to do tool tips so we can draw tips for the renderers
ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
toolTipManager.registerComponent(this);
setAutoscrolls(true);
| public boolean | isCellEditable(int row, int column)Returns true if the cell at 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.
return getModel().isCellEditable(row, convertColumnIndexToModel(column));
| public 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.
if (!getRowSelectionAllowed() && !getColumnSelectionAllowed()) {
return false;
}
return (!getRowSelectionAllowed() || isRowSelected(row)) &&
(!getColumnSelectionAllowed() || isColumnSelected(column));
| public 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.
return columnModel.getSelectionModel().isSelectedIndex(column);
| public boolean | isEditing()Returns true if a cell is being edited.
return (cellEditor == null)? false : true;
| public 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.
return selectionModel.isSelectedIndex(row);
| private int | limit(int i, int a, int b)
return Math.min(b, Math.max(i, a));
| public void | moveColumn(int column, int targetColumn)Moves the column column to the position currently
occupied by the column targetColumn in the view.
The old column at targetColumn is
shifted left or right to make room.
getColumnModel().moveColumn(column, targetColumn);
| protected java.lang.String | paramString()Returns a string representation of this table. This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null .
String gridColorString = (gridColor != null ?
gridColor.toString() : "");
String showHorizontalLinesString = (showHorizontalLines ?
"true" : "false");
String showVerticalLinesString = (showVerticalLines ?
"true" : "false");
String autoResizeModeString;
if (autoResizeMode == AUTO_RESIZE_OFF) {
autoResizeModeString = "AUTO_RESIZE_OFF";
} else if (autoResizeMode == AUTO_RESIZE_NEXT_COLUMN) {
autoResizeModeString = "AUTO_RESIZE_NEXT_COLUMN";
} else if (autoResizeMode == AUTO_RESIZE_SUBSEQUENT_COLUMNS) {
autoResizeModeString = "AUTO_RESIZE_SUBSEQUENT_COLUMNS";
} else if (autoResizeMode == AUTO_RESIZE_LAST_COLUMN) {
autoResizeModeString = "AUTO_RESIZE_LAST_COLUMN";
} else if (autoResizeMode == AUTO_RESIZE_ALL_COLUMNS) {
autoResizeModeString = "AUTO_RESIZE_ALL_COLUMNS";
} else autoResizeModeString = "";
String autoCreateColumnsFromModelString = (autoCreateColumnsFromModel ?
"true" : "false");
String preferredViewportSizeString = (preferredViewportSize != null ?
preferredViewportSize.toString()
: "");
String rowSelectionAllowedString = (rowSelectionAllowed ?
"true" : "false");
String cellSelectionEnabledString = (cellSelectionEnabled ?
"true" : "false");
String selectionForegroundString = (selectionForeground != null ?
selectionForeground.toString() :
"");
String selectionBackgroundString = (selectionBackground != null ?
selectionBackground.toString() :
"");
return super.paramString() +
",autoCreateColumnsFromModel=" + autoCreateColumnsFromModelString +
",autoResizeMode=" + autoResizeModeString +
",cellSelectionEnabled=" + cellSelectionEnabledString +
",editingColumn=" + editingColumn +
",editingRow=" + editingRow +
",gridColor=" + gridColorString +
",preferredViewportSize=" + preferredViewportSizeString +
",rowHeight=" + rowHeight +
",rowMargin=" + rowMargin +
",rowSelectionAllowed=" + rowSelectionAllowedString +
",selectionBackground=" + selectionBackgroundString +
",selectionForeground=" + selectionForegroundString +
",showHorizontalLines=" + showHorizontalLinesString +
",showVerticalLines=" + showVerticalLinesString;
| public java.awt.Component | prepareEditor(javax.swing.table.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 .
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.
Object value = getValueAt(row, column);
boolean isSelected = isCellSelected(row, column);
Component comp = editor.getTableCellEditorComponent(this, value, isSelected,
row, column);
if (comp instanceof JComponent) {
JComponent jComp = (JComponent)comp;
if (jComp.getNextFocusableComponent() == null) {
jComp.setNextFocusableComponent(this);
}
}
return comp;
| public java.awt.Component | prepareRenderer(javax.swing.table.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 .
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.
Object value = getValueAt(row, column);
boolean isSelected = false;
boolean hasFocus = false;
// Only indicate the selection and focused cell if not printing
if (!isPrinting) {
isSelected = isCellSelected(row, column);
boolean rowIsLead =
(selectionModel.getLeadSelectionIndex() == row);
boolean colIsLead =
(columnModel.getSelectionModel().getLeadSelectionIndex() == column);
hasFocus = (rowIsLead && colIsLead) && isFocusOwner();
}
return renderer.getTableCellRendererComponent(this, value,
isSelected, hasFocus,
row, column);
| public 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. A modal progress dialog, with an abort
option, will be shown for the duration of printing.
Note: In headless mode, no dialogs will be shown.
return print(PrintMode.FIT_WIDTH);
| public boolean | print(javax.swing.JTable$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. A modal progress dialog, with an abort
option, will be shown for the duration of printing.
Note: In headless mode, no dialogs will be shown.
return print(printMode, null, null);
| public boolean | print(javax.swing.JTable$PrintMode printMode, java.text.MessageFormat headerFormat, java.text.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. A modal progress dialog,
with an abort option, will be shown for the duration of printing.
Note: In headless mode, no dialogs will be shown.
boolean showDialogs = !GraphicsEnvironment.isHeadless();
return print(printMode, headerFormat, footerFormat,
showDialogs, null, showDialogs);
| public boolean | print(javax.swing.JTable$PrintMode printMode, java.text.MessageFormat headerFormat, java.text.MessageFormat footerFormat, boolean showPrintDialog, javax.print.attribute.PrintRequestAttributeSet attr, boolean interactive)Print this JTable . Takes steps that the majority of
developers would take in order to print a JTable .
In short, it prepares the table, calls getPrintable to
fetch an appropriate Printable , and then sends it to the
printer.
A boolean parameter allows you to specify whether or not
a printing dialog is displayed to the user. When it is, the user may
use the dialog to change printing attributes or even cancel the print.
Another parameter allows for printing attributes to be specified
directly. This can be used either to provide the initial values for the
print dialog, or to supply any needed attributes when the dialog is not
shown.
A second boolean parameter allows you to specify whether
or not to perform printing in an interactive mode. If true ,
a modal progress dialog, with an abort option, is displayed for the
duration of printing . This dialog also prevents any user action which
may affect the table. However, it can not prevent the table from being
modified by code (for example, another thread that posts updates using
SwingUtilities.invokeLater ). It is therefore the
responsibility of the developer to ensure that no other code modifies
the table in any way during printing (invalid modifications include
changes in: size, renderers, or underlying data). Printing behavior is
undefined when the table is changed during printing.
If false is specified for this parameter, no dialog will
be displayed and printing will begin immediately on the event-dispatch
thread. This blocks any other events, including repaints, from being
processed until printing is complete. Although this effectively prevents
the table from being changed, it doesn't provide a good user experience.
For this reason, specifying false is only recommended when
printing from an application with no visible GUI.
Note: Attempting to show the printing dialog or run interactively, while
in headless mode, will result in a HeadlessException .
Before fetching the printable, this method prepares the table in order
to get the most desirable printed result. If the table is currently
in an editing mode, it terminates the editing as gracefully as
possible. It also ensures that the the table's current selection and
focused cell are not indicated in the printed output. This is handled on
the view level, and only for the duration of the printing, thus no
notification needs to be sent to the selection models.
See {@link #getPrintable} for further description on how the
table is printed.
// complain early if an invalid parameter is specified for headless mode
boolean isHeadless = GraphicsEnvironment.isHeadless();
if (isHeadless) {
if (showPrintDialog) {
throw new HeadlessException("Can't show print dialog.");
}
if (interactive) {
throw new HeadlessException("Can't run interactively.");
}
}
if (isEditing()) {
// try to stop cell editing, and failing that, cancel it
if (!getCellEditor().stopCellEditing()) {
getCellEditor().cancelCellEditing();
}
}
if (attr == null) {
attr = new HashPrintRequestAttributeSet();
}
// get a PrinterJob
final PrinterJob job = PrinterJob.getPrinterJob();
// fetch the Printable
Printable printable =
getPrintable(printMode, headerFormat, footerFormat);
if (interactive) {
// wrap the Printable so that we can print on another thread
printable = new ThreadSafePrintable(printable);
}
// set the printable on the PrinterJob
job.setPrintable(printable);
// if requested, show the print dialog
if (showPrintDialog && !job.printDialog(attr)) {
// the user cancelled the print dialog
return false;
}
// if not interactive, just print on this thread (no dialog)
if (!interactive) {
// set a flag to hide the selection and focused cell
isPrinting = true;
try {
// do the printing
job.print(attr);
} finally {
// restore the flag
isPrinting = false;
}
// we're done
return true;
}
// interactive, drive printing from another thread
// and show a modal status dialog for the duration
// prepare the status JOptionPane
String progressTitle =
UIManager.getString("PrintingDialog.titleProgressText");
String dialogInitialContent =
UIManager.getString("PrintingDialog.contentInitialText");
// this one's a MessageFormat since it must include the page
// number in its text
MessageFormat statusFormat =
new MessageFormat(
UIManager.getString("PrintingDialog.contentProgressText"));
String abortText =
UIManager.getString("PrintingDialog.abortButtonText");
String abortTooltip =
UIManager.getString("PrintingDialog.abortButtonToolTipText");
int abortMnemonic =
UIManager.getInt("PrintingDialog.abortButtonMnemonic", -1);
int abortMnemonicIndex =
UIManager.getInt("PrintingDialog.abortButtonDisplayedMnemonicIndex", -1);
final JButton abortButton = new JButton(abortText);
abortButton.setToolTipText(abortTooltip);
if (abortMnemonic != -1) {
abortButton.setMnemonic(abortMnemonic);
}
if (abortMnemonicIndex != -1) {
abortButton.setDisplayedMnemonicIndex(abortMnemonicIndex);
}
final JLabel statusLabel = new JLabel(dialogInitialContent);
JOptionPane abortPane = new JOptionPane(statusLabel,
JOptionPane.INFORMATION_MESSAGE,
JOptionPane.DEFAULT_OPTION,
null, new Object[] {abortButton},
abortButton);
// need a final reference to the printable for later
final ThreadSafePrintable wrappedPrintable =
(ThreadSafePrintable)printable;
// set the label which the wrapped printable will update
wrappedPrintable.startUpdatingStatus(statusFormat, statusLabel);
// The dialog should be centered over the viewport if the table is in one
Container parentComp = getParent() instanceof JViewport ? getParent() : this;
// create the dialog to display the JOptionPane
final JDialog abortDialog = abortPane.createDialog(parentComp, progressTitle);
// clicking the X button should not hide the dialog
abortDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
// the action that will abort printing
final Action abortAction = new AbstractAction() {
boolean isAborted = false;
public void actionPerformed(ActionEvent ae) {
if (!isAborted) {
isAborted = true;
// update the status dialog to indicate aborting
abortButton.setEnabled(false);
abortDialog.setTitle(
UIManager.getString("PrintingDialog.titleAbortingText"));
statusLabel.setText(
UIManager.getString("PrintingDialog.contentAbortingText"));
// we don't want the aborting status message to be clobbered
wrappedPrintable.stopUpdatingStatus();
// cancel the PrinterJob
job.cancel();
}
}
};
// clicking the abort button should abort printing
abortButton.addActionListener(abortAction);
// the look and feels set up a close action (typically bound
// to ESCAPE) that also needs to be modified to simply abort
// printing
abortPane.getActionMap().put("close", abortAction);
// clicking the X button should also abort printing
final WindowAdapter closeListener = new WindowAdapter() {
public void windowClosing(WindowEvent we) {
abortAction.actionPerformed(null);
}
};
abortDialog.addWindowListener(closeListener);
// make sure this is clear since we'll check it after
printError = null;
// to synchronize on
final Object lock = new Object();
// copied so we can access from the inner class
final PrintRequestAttributeSet copyAttr = attr;
// this runnable will be used to do the printing
// (and save any throwables) on another thread
Runnable runnable = new Runnable() {
public void run() {
try {
// do the printing
job.print(copyAttr);
} catch (Throwable t) {
// save any Throwable to be rethrown
synchronized(lock) {
printError = t;
}
} finally {
// we're finished - hide the dialog, allowing
// processing in the original EDT to continue
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// don't want to notify the abort action
abortDialog.removeWindowListener(closeListener);
abortDialog.dispose();
}
});
}
}
};
// start printing on another thread
Thread th = new Thread(runnable);
th.start();
// show the modal status dialog (and wait for it to be hidden)
abortDialog.setVisible(true);
// dialog has been hidden
// look for any error that the printing may have generated
Throwable pe;
synchronized(lock) {
pe = printError;
printError = null;
}
// check the type of error and handle it
if (pe != null) {
// a subclass of PrinterException meaning the job was aborted,
// in this case, by the user
if (pe instanceof PrinterAbortException) {
return false;
} else if (pe instanceof PrinterException) {
throw (PrinterException)pe;
} else if (pe instanceof RuntimeException) {
throw (RuntimeException)pe;
} else if (pe instanceof Error) {
throw (Error)pe;
}
// can not happen
throw new AssertionError(pe);
}
return true;
| protected boolean | processKeyBinding(javax.swing.KeyStroke ks, java.awt.event.KeyEvent e, int condition, boolean pressed)
boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
// Start editing when a key is typed. UI classes can disable this behavior
// by setting the client property JTable.autoStartsEdit to Boolean.FALSE.
if (!retValue && condition == WHEN_ANCESTOR_OF_FOCUSED_COMPONENT &&
isFocusOwner() &&
!Boolean.FALSE.equals((Boolean)getClientProperty("JTable.autoStartsEdit"))) {
// We do not have a binding for the event.
Component editorComponent = getEditorComponent();
if (editorComponent == null) {
// Only attempt to install the editor on a KEY_PRESSED,
if (e == null || e.getID() != KeyEvent.KEY_PRESSED) {
return false;
}
// Don't start when just a modifier is pressed
int code = e.getKeyCode();
if (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL ||
code == KeyEvent.VK_ALT) {
return false;
}
// Try to install the editor
int leadRow = getSelectionModel().getLeadSelectionIndex();
int leadColumn = getColumnModel().getSelectionModel().
getLeadSelectionIndex();
if (leadRow != -1 && leadColumn != -1 && !isEditing()) {
if (!editCellAt(leadRow, leadColumn)) {
return false;
}
}
editorComponent = getEditorComponent();
if (editorComponent == null) {
return false;
}
}
// If the editorComponent is a JComponent, pass the event to it.
if (editorComponent instanceof JComponent) {
retValue = ((JComponent)editorComponent).processKeyBinding
(ks, e, WHEN_FOCUSED, pressed);
// If we have started an editor as a result of the user
// pressing a key and the surrendersFocusOnKeystroke property
// is true, give the focus to the new editor.
if (getSurrendersFocusOnKeystroke()) {
editorComponent.requestFocus();
}
}
}
return retValue;
| private void | readObject(java.io.ObjectInputStream s)
s.defaultReadObject();
if ((ui != null) && (getUIClassID().equals(uiClassID))) {
ui.installUI(this);
}
createDefaultRenderers();
createDefaultEditors();
// If ToolTipText != null, then the tooltip has already been
// registered by JComponent.readObject() and we don't want
// to re-register here
if (getToolTipText() == null) {
ToolTipManager.sharedInstance().registerComponent(this);
}
| public void | removeColumn(javax.swing.table.TableColumn aColumn)Removes aColumn from this JTable 's
array of columns. Note: this method does not remove the column
of data from the model; it just removes the TableColumn
that was responsible for displaying it.
getColumnModel().removeColumn(aColumn);
| public void | removeColumnSelectionInterval(int index0, int index1)Deselects the columns from index0 to index1 , inclusive.
columnModel.getSelectionModel().removeSelectionInterval(boundColumn(index0), boundColumn(index1));
| public void | removeEditor()Discards the editor object and frees the real estate it used for
cell rendering.
KeyboardFocusManager.getCurrentKeyboardFocusManager().
removePropertyChangeListener("permanentFocusOwner", editorRemover);
editorRemover = null;
TableCellEditor editor = getCellEditor();
if(editor != null) {
editor.removeCellEditorListener(this);
if (editorComp != null) {
remove(editorComp);
}
Rectangle cellRect = getCellRect(editingRow, editingColumn, false);
setCellEditor(null);
setEditingColumn(-1);
setEditingRow(-1);
editorComp = null;
repaint(cellRect);
}
| public void | removeNotify()Calls the unconfigureEnclosingScrollPane method.
KeyboardFocusManager.getCurrentKeyboardFocusManager().
removePropertyChangeListener("permanentFocusOwner", editorRemover);
editorRemover = null;
unconfigureEnclosingScrollPane();
super.removeNotify();
| public void | removeRowSelectionInterval(int index0, int index1)Deselects the rows from index0 to index1 , inclusive.
selectionModel.removeSelectionInterval(boundRow(index0), boundRow(index1));
| protected void | resizeAndRepaint()Equivalent to revalidate followed by repaint .
revalidate();
repaint();
| public int | rowAtPoint(java.awt.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].
int y = point.y;
int result = (rowModel == null) ? y/getRowHeight() : rowModel.getIndex(y);
if (result < 0) {
return -1;
}
else if (result >= getRowCount()) {
return -1;
}
else {
return result;
}
| public void | selectAll()Selects all rows, columns, and cells in the table.
// If I'm currently editing, then I should stop editing
if (isEditing()) {
removeEditor();
}
if (getRowCount() > 0 && getColumnCount() > 0) {
int oldLead;
int oldAnchor;
ListSelectionModel selModel;
selModel = selectionModel;
selModel.setValueIsAdjusting(true);
oldLead = selModel.getLeadSelectionIndex();
oldAnchor = selModel.getAnchorSelectionIndex();
setRowSelectionInterval(0, getRowCount()-1);
// this is done only to restore the anchor and lead
selModel.addSelectionInterval(oldAnchor, oldLead);
selModel.setValueIsAdjusting(false);
selModel = columnModel.getSelectionModel();
selModel.setValueIsAdjusting(true);
oldLead = selModel.getLeadSelectionIndex();
oldAnchor = selModel.getAnchorSelectionIndex();
setColumnSelectionInterval(0, getColumnCount()-1);
// this is done only to restore the anchor and lead
selModel.addSelectionInterval(oldAnchor, oldLead);
selModel.setValueIsAdjusting(false);
}
| public void | setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel)Sets this table's autoCreateColumnsFromModel flag.
This method calls createDefaultColumnsFromModel if
autoCreateColumnsFromModel changes from false to true.
if (this.autoCreateColumnsFromModel != autoCreateColumnsFromModel) {
boolean old = this.autoCreateColumnsFromModel;
this.autoCreateColumnsFromModel = autoCreateColumnsFromModel;
if (autoCreateColumnsFromModel) {
createDefaultColumnsFromModel();
}
firePropertyChange("autoCreateColumnsFromModel", old, autoCreateColumnsFromModel);
}
| public void | setAutoResizeMode(int mode)Sets the table's auto resize mode when the table is resized.
if ((mode == AUTO_RESIZE_OFF) ||
(mode == AUTO_RESIZE_NEXT_COLUMN) ||
(mode == AUTO_RESIZE_SUBSEQUENT_COLUMNS) ||
(mode == AUTO_RESIZE_LAST_COLUMN) ||
(mode == AUTO_RESIZE_ALL_COLUMNS)) {
int old = autoResizeMode;
autoResizeMode = mode;
resizeAndRepaint();
if (tableHeader != null) {
tableHeader.resizeAndRepaint();
}
firePropertyChange("autoResizeMode", old, autoResizeMode);
}
| public void | setCellEditor(javax.swing.table.TableCellEditor anEditor)Sets the cellEditor variable.
TableCellEditor oldEditor = cellEditor;
cellEditor = anEditor;
firePropertyChange("tableCellEditor", oldEditor, anEditor);
| public void | setCellSelectionEnabled(boolean cellSelectionEnabled)Sets whether this table allows both a column selection and a
row selection to exist simultaneously. When set,
the table treats the intersection of the row and column selection
models as the selected cells. Override isCellSelected to
change this default behavior. This method is equivalent to setting
both the rowSelectionAllowed property and
columnSelectionAllowed property of the
columnModel to the supplied value.
setRowSelectionAllowed(cellSelectionEnabled);
setColumnSelectionAllowed(cellSelectionEnabled);
boolean old = this.cellSelectionEnabled;
this.cellSelectionEnabled = cellSelectionEnabled;
firePropertyChange("cellSelectionEnabled", old, cellSelectionEnabled);
| public void | setColumnModel(javax.swing.table.TableColumnModel columnModel)Sets the column model for this table to newModel and registers
for listener notifications from the new column model. Also sets
the column model of the JTableHeader to columnModel .
if (columnModel == null) {
throw new IllegalArgumentException("Cannot set a null ColumnModel");
}
TableColumnModel old = this.columnModel;
if (columnModel != old) {
if (old != null) {
old.removeColumnModelListener(this);
}
this.columnModel = columnModel;
columnModel.addColumnModelListener(this);
// Set the column model of the header as well.
if (tableHeader != null) {
tableHeader.setColumnModel(columnModel);
}
firePropertyChange("columnModel", old, columnModel);
resizeAndRepaint();
}
| public void | setColumnSelectionAllowed(boolean columnSelectionAllowed)Sets whether the columns in this model can be selected.
boolean old = columnModel.getColumnSelectionAllowed();
columnModel.setColumnSelectionAllowed(columnSelectionAllowed);
if (old != columnSelectionAllowed) {
repaint();
}
firePropertyChange("columnSelectionAllowed", old, columnSelectionAllowed);
| public void | setColumnSelectionInterval(int index0, int index1)Selects the columns from index0 to index1 ,
inclusive.
columnModel.getSelectionModel().setSelectionInterval(boundColumn(index0), boundColumn(index1));
| public void | setDefaultEditor(java.lang.Class columnClass, javax.swing.table.TableCellEditor editor)Sets a default cell editor to be used if no editor has been set in
a TableColumn . If no editing is required in a table, or a
particular column in a table, uses the isCellEditable
method in the TableModel interface to ensure that this
JTable will not start an editor in these columns.
If editor is null , removes the default editor for this
column class.
if (editor != null) {
defaultEditorsByColumnClass.put(columnClass, editor);
}
else {
defaultEditorsByColumnClass.remove(columnClass);
}
| public void | setDefaultRenderer(java.lang.Class columnClass, javax.swing.table.TableCellRenderer renderer)Sets a default cell renderer to be used if no renderer has been set in
a TableColumn . If renderer is null ,
removes the default renderer for this column class.
if (renderer != null) {
defaultRenderersByColumnClass.put(columnClass, renderer);
}
else {
defaultRenderersByColumnClass.remove(columnClass);
}
| public void | setDragEnabled(boolean b)Sets the dragEnabled property,
which must be true to enable
automatic drag handling (the first part of drag and drop)
on this component.
The transferHandler property needs to be set
to a non-null value for the drag to do
anything. The default value of the dragEnabled false.
When automatic drag handling is enabled,
most look and feels begin a drag-and-drop operation
whenever the user presses the mouse button over a selection
and then moves the mouse a few pixels.
Setting this property to true
can therefore have a subtle effect on
how selections behave.
Some look and feels might not support automatic drag and drop;
they will ignore this property. You can work around such
look and feels by modifying the component
to directly call the exportAsDrag method of a
TransferHandler .
if (b && GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
dragEnabled = b;
| public void | setEditingColumn(int aColumn)Sets the editingColumn variable.
editingColumn = aColumn;
| public void | setEditingRow(int aRow)Sets the editingRow variable.
editingRow = aRow;
| public void | setGridColor(java.awt.Color gridColor)Sets the color used to draw grid lines to gridColor and redisplays.
The default color is look and feel dependent.
if (gridColor == null) {
throw new IllegalArgumentException("New color is null");
}
Color old = this.gridColor;
this.gridColor = gridColor;
firePropertyChange("gridColor", old, gridColor);
// Redraw
repaint();
| public void | setIntercellSpacing(java.awt.Dimension intercellSpacing)Sets the rowMargin and the columnMargin --
the height and width of the space between cells -- to
intercellSpacing .
// Set the rowMargin here and columnMargin in the TableColumnModel
setRowMargin(intercellSpacing.height);
getColumnModel().setColumnMargin(intercellSpacing.width);
resizeAndRepaint();
| private void | setLazyEditor(java.lang.Class c, java.lang.String s)
setLazyValue(defaultEditorsByColumnClass, c, s);
| private void | setLazyRenderer(java.lang.Class c, java.lang.String s)
setLazyValue(defaultRenderersByColumnClass, c, s);
| private void | setLazyValue(java.util.Hashtable h, java.lang.Class c, java.lang.String s)
h.put(c, new UIDefaults.ProxyLazyValue(s));
| public void | setModel(javax.swing.table.TableModel dataModel)Sets the data model for this table to newModel and registers
with it for listener notifications from the new data model.
if (dataModel == null) {
throw new IllegalArgumentException("Cannot set a null TableModel");
}
if (this.dataModel != dataModel) {
TableModel old = this.dataModel;
if (old != null) {
old.removeTableModelListener(this);
}
this.dataModel = dataModel;
dataModel.addTableModelListener(this);
tableChanged(new TableModelEvent(dataModel, TableModelEvent.HEADER_ROW));
firePropertyChange("model", old, dataModel);
}
| public void | setPreferredScrollableViewportSize(java.awt.Dimension size)Sets the preferred size of the viewport for this table.
preferredViewportSize = size;
| public void | setRowHeight(int rowHeight)Sets the height, in pixels, of all cells to rowHeight ,
revalidates, and repaints.
The height of the cells will be equal to the row height minus
the row margin.
if (rowHeight <= 0) {
throw new IllegalArgumentException("New row height less than 1");
}
int old = this.rowHeight;
this.rowHeight = rowHeight;
rowModel = null;
isRowHeightSet = true;
resizeAndRepaint();
firePropertyChange("rowHeight", old, rowHeight);
| public void | setRowHeight(int row, int rowHeight)Sets the height for row to rowHeight ,
revalidates, and repaints. The height of the cells in this row
will be equal to the row height minus the row margin.
if (rowHeight <= 0) {
throw new IllegalArgumentException("New row height less than 1");
}
getRowModel().setSize(row, rowHeight);
resizeAndRepaint();
| public void | setRowMargin(int rowMargin)Sets the amount of empty space between cells in adjacent rows.
int old = this.rowMargin;
this.rowMargin = rowMargin;
resizeAndRepaint();
firePropertyChange("rowMargin", old, rowMargin);
| public void | setRowSelectionAllowed(boolean rowSelectionAllowed)Sets whether the rows in this model can be selected.
boolean old = this.rowSelectionAllowed;
this.rowSelectionAllowed = rowSelectionAllowed;
if (old != rowSelectionAllowed) {
repaint();
}
firePropertyChange("rowSelectionAllowed", old, rowSelectionAllowed);
| public void | setRowSelectionInterval(int index0, int index1)Selects the rows from index0 to index1 ,
inclusive.
selectionModel.setSelectionInterval(boundRow(index0), boundRow(index1));
| public void | setSelectionBackground(java.awt.Color selectionBackground)Sets the background color for selected cells. Cell renderers
can use this color to the fill selected cells.
The default value of this property is defined by the look
and feel implementation.
This is a JavaBeans bound property.
Color old = this.selectionBackground;
this.selectionBackground = selectionBackground;
firePropertyChange("selectionBackground", old, selectionBackground);
if ( !selectionBackground.equals(old) )
{
repaint();
}
| public void | setSelectionForeground(java.awt.Color selectionForeground)Sets the foreground color for selected cells. Cell renderers
can use this color to render text and graphics for selected
cells.
The default value of this property is defined by the look
and feel implementation.
This is a JavaBeans bound property.
Color old = this.selectionForeground;
this.selectionForeground = selectionForeground;
firePropertyChange("selectionForeground", old, selectionForeground);
if ( !selectionForeground.equals(old) )
{
repaint();
}
| public void | setSelectionMode(int selectionMode)Sets the table's selection mode to allow only single selections, a single
contiguous interval, or multiple intervals.
Note:
JTable provides all the methods for handling
column and row selection. When setting states,
such as setSelectionMode , it not only
updates the mode for the row selection model but also sets similar
values in the selection model of the columnModel .
If you want to have the row and column selection models operating
in different modes, set them both directly.
Both the row and column selection models for JTable
default to using a DefaultListSelectionModel
so that JTable works the same way as the
JList . See the setSelectionMode method
in JList for details about the modes.
clearSelection();
getSelectionModel().setSelectionMode(selectionMode);
getColumnModel().getSelectionModel().setSelectionMode(selectionMode);
| public void | setSelectionModel(javax.swing.ListSelectionModel newModel)Sets the row selection model for this table to newModel
and registers for listener notifications from the new selection model.
if (newModel == null) {
throw new IllegalArgumentException("Cannot set a null SelectionModel");
}
ListSelectionModel oldModel = selectionModel;
if (newModel != oldModel) {
if (oldModel != null) {
oldModel.removeListSelectionListener(this);
}
selectionModel = newModel;
newModel.addListSelectionListener(this);
firePropertyChange("selectionModel", oldModel, newModel);
repaint();
checkLeadAnchor();
}
| public void | setShowGrid(boolean showGrid)Sets whether the table draws grid lines around cells.
If showGrid is true it does; if it is false it doesn't.
There is no getShowGrid method as this state is held
in two variables -- showHorizontalLines and showVerticalLines --
each of which can be queried independently.
setShowHorizontalLines(showGrid);
setShowVerticalLines(showGrid);
// Redraw
repaint();
| public void | setShowHorizontalLines(boolean showHorizontalLines)Sets whether the table draws horizontal lines between cells.
If showHorizontalLines is true it does; if it is false it doesn't.
boolean old = this.showHorizontalLines;
this.showHorizontalLines = showHorizontalLines;
firePropertyChange("showHorizontalLines", old, showHorizontalLines);
// Redraw
repaint();
| public void | setShowVerticalLines(boolean showVerticalLines)Sets whether the table draws vertical lines between cells.
If showVerticalLines is true it does; if it is false it doesn't.
boolean old = this.showVerticalLines;
this.showVerticalLines = showVerticalLines;
firePropertyChange("showVerticalLines", old, showVerticalLines);
// Redraw
repaint();
| public 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.
By default, this property is false, and the JTable
retains the focus unless the cell is clicked.
this.surrendersFocusOnKeystroke = surrendersFocusOnKeystroke;
| public void | setTableHeader(javax.swing.table.JTableHeader tableHeader)Sets the tableHeader working with this JTable to newHeader .
It is legal to have a null tableHeader .
if (this.tableHeader != tableHeader) {
JTableHeader old = this.tableHeader;
// Release the old header
if (old != null) {
old.setTable(null);
}
this.tableHeader = tableHeader;
if (tableHeader != null) {
tableHeader.setTable(this);
}
firePropertyChange("tableHeader", old, tableHeader);
}
| public void | setUI(javax.swing.plaf.TableUI ui)Sets the L&F object that renders this component and repaints.
if (this.ui != ui) {
super.setUI(ui);
repaint();
}
| void | setUIProperty(java.lang.String propertyName, java.lang.Object value)
if (propertyName == "rowHeight") {
if (!isRowHeightSet) {
setRowHeight(((Number)value).intValue());
isRowHeightSet = false;
}
return;
}
super.setUIProperty(propertyName, value);
| public void | setValueAt(java.lang.Object aValue, int row, int column)Sets the value for the cell in the table model at 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.
aValue is the new value.
getModel().setValueAt(aValue, row, convertColumnIndexToModel(column));
| private void | setWidthsFromPreferredWidths(boolean inverse)
int totalWidth = getWidth();
int totalPreferred = getPreferredSize().width;
int target = !inverse ? totalWidth : totalPreferred;
final TableColumnModel cm = columnModel;
Resizable3 r = new Resizable3() {
public int getElementCount() { return cm.getColumnCount(); }
public int getLowerBoundAt(int i) { return cm.getColumn(i).getMinWidth(); }
public int getUpperBoundAt(int i) { return cm.getColumn(i).getMaxWidth(); }
public int getMidPointAt(int i) {
if (!inverse) {
return cm.getColumn(i).getPreferredWidth();
}
else {
return cm.getColumn(i).getWidth();
}
}
public void setSizeAt(int s, int i) {
if (!inverse) {
cm.getColumn(i).setWidth(s);
}
else {
cm.getColumn(i).setPreferredWidth(s);
}
}
};
adjustSizes(target, r, inverse);
| public void | sizeColumnsToFit(boolean lastColumnOnly)Sizes the table columns to fit the available space.
int oldAutoResizeMode = autoResizeMode;
setAutoResizeMode(lastColumnOnly ? AUTO_RESIZE_LAST_COLUMN
: AUTO_RESIZE_ALL_COLUMNS);
sizeColumnsToFit(-1);
setAutoResizeMode(oldAutoResizeMode);
| public void | sizeColumnsToFit(int resizingColumn)Obsolete as of Java 2 platform v1.4. Please use the
doLayout() method instead.
if (resizingColumn == -1) {
setWidthsFromPreferredWidths(false);
}
else {
if (autoResizeMode == AUTO_RESIZE_OFF) {
TableColumn aColumn = getColumnModel().getColumn(resizingColumn);
aColumn.setPreferredWidth(aColumn.getWidth());
}
else {
int delta = getWidth() - getColumnModel().getTotalColumnWidth();
accommodateDelta(resizingColumn, delta);
setWidthsFromPreferredWidths(true);
}
}
| public void | tableChanged(javax.swing.event.TableModelEvent e)Invoked when this table's 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.
if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW) {
// The whole thing changed
clearSelection();
checkLeadAnchor();
rowModel = null;
if (getAutoCreateColumnsFromModel()) {
// This will effect invalidation of the JTable and JTableHeader.
createDefaultColumnsFromModel();
return;
}
resizeAndRepaint();
return;
}
// The totalRowHeight calculated below will be incorrect if
// there are variable height rows. Repaint the visible region,
// but don't return as a revalidate may be necessary as well.
if (rowModel != null) {
repaint();
}
if (e.getType() == TableModelEvent.INSERT) {
tableRowsInserted(e);
return;
}
if (e.getType() == TableModelEvent.DELETE) {
tableRowsDeleted(e);
return;
}
int modelColumn = e.getColumn();
int start = e.getFirstRow();
int end = e.getLastRow();
Rectangle dirtyRegion;
if (modelColumn == TableModelEvent.ALL_COLUMNS) {
// 1 or more rows changed
dirtyRegion = new Rectangle(0, start * getRowHeight(),
getColumnModel().getTotalColumnWidth(), 0);
}
else {
// A cell or column of cells has changed.
// Unlike the rest of the methods in the JTable, the TableModelEvent
// uses the coordinate system of the model instead of the view.
// This is the only place in the JTable where this "reverse mapping"
// is used.
int column = convertColumnIndexToView(modelColumn);
dirtyRegion = getCellRect(start, column, false);
}
// Now adjust the height of the dirty region according to the value of "end".
// Check for Integer.MAX_VALUE as this will cause an overflow.
if (end != Integer.MAX_VALUE) {
dirtyRegion.height = (end-start+1)*getRowHeight();
repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height);
}
// In fact, if the end is Integer.MAX_VALUE we need to revalidate anyway
// because the scrollbar may need repainting.
else {
clearSelection();
resizeAndRepaint();
rowModel = null;
}
| private void | tableRowsDeleted(javax.swing.event.TableModelEvent e)
int start = e.getFirstRow();
int end = e.getLastRow();
if (start < 0) {
start = 0;
}
if (end < 0) {
end = getRowCount()-1;
}
int deletedCount = end - start + 1;
int previousRowCount = getRowCount() + deletedCount;
// Adjust the selection to account for the new rows
selectionModel.removeIndexInterval(start, end);
checkLeadAnchor();
// If we have variable height rows, adjust the row model.
if (rowModel != null) {
rowModel.removeEntries(start, deletedCount);
}
int rh = getRowHeight();
Rectangle drawRect = new Rectangle(0, start * rh,
getColumnModel().getTotalColumnWidth(),
(previousRowCount - start) * rh);
revalidate();
// PENDING(milne) revalidate calls repaint() if parent is a ScrollPane
// repaint still required in the unusual case where there is no ScrollPane
repaint(drawRect);
| private void | tableRowsInserted(javax.swing.event.TableModelEvent e)
int start = e.getFirstRow();
int end = e.getLastRow();
if (start < 0) {
start = 0;
}
if (end < 0) {
end = getRowCount()-1;
}
// Adjust the selection to account for the new rows.
int length = end - start + 1;
selectionModel.insertIndexInterval(start, length, true);
checkLeadAnchor();
// If we have variable height rows, adjust the row model.
if (rowModel != null) {
rowModel.insertEntries(start, length, getRowHeight());
}
int rh = getRowHeight() ;
Rectangle drawRect = new Rectangle(0, start * rh,
getColumnModel().getTotalColumnWidth(),
(getRowCount()-start) * rh);
revalidate();
// PENDING(milne) revalidate calls repaint() if parent is a ScrollPane
// repaint still required in the unusual case where there is no ScrollPane
repaint(drawRect);
| protected void | unconfigureEnclosingScrollPane()Reverses the effect of configureEnclosingScrollPane
by replacing the columnHeaderView of the enclosing
scroll pane with null . JTable 's
removeNotify method calls
this method, which is protected so that this default uninstallation
procedure can be overridden by a subclass.
Container p = getParent();
if (p instanceof JViewport) {
Container gp = p.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
// Make certain we are the viewPort's view and not, for
// example, the rowHeaderView of the scrollPane -
// an implementor of fixed columns might do this.
JViewport viewport = scrollPane.getViewport();
if (viewport == null || viewport.getView() != this) {
return;
}
scrollPane.setColumnHeaderView(null);
}
}
| private void | updateSubComponentUI(java.lang.Object componentShell)
if (componentShell == null) {
return;
}
Component component = null;
if (componentShell instanceof Component) {
component = (Component)componentShell;
}
if (componentShell instanceof DefaultCellEditor) {
component = ((DefaultCellEditor)componentShell).getComponent();
}
if (component != null && component instanceof JComponent) {
((JComponent)component).updateUI();
}
| public void | updateUI()Notification from the UIManager that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager .
// Update the UIs of the cell renderers, cell editors and header renderers.
TableColumnModel cm = getColumnModel();
for(int column = 0; column < cm.getColumnCount(); column++) {
TableColumn aColumn = cm.getColumn(column);
updateSubComponentUI(aColumn.getCellRenderer());
updateSubComponentUI(aColumn.getCellEditor());
updateSubComponentUI(aColumn.getHeaderRenderer());
}
// Update the UIs of all the default renderers.
Enumeration defaultRenderers = defaultRenderersByColumnClass.elements();
while (defaultRenderers.hasMoreElements()) {
updateSubComponentUI(defaultRenderers.nextElement());
}
// Update the UIs of all the default editors.
Enumeration defaultEditors = defaultEditorsByColumnClass.elements();
while (defaultEditors.hasMoreElements()) {
updateSubComponentUI(defaultEditors.nextElement());
}
// Update the UI of the table header
if (tableHeader != null && tableHeader.getParent() == null) {
tableHeader.updateUI();
}
setUI((TableUI)UIManager.getUI(this));
resizeAndRepaint();
| public void | valueChanged(javax.swing.event.ListSelectionEvent e)Invoked when the row selection changes -- repaints to show the new
selection.
Application code will not use these methods explicitly, they
are used internally by JTable.
boolean isAdjusting = e.getValueIsAdjusting();
if (rowSelectionAdjusting && !isAdjusting) {
// The assumption is that when the model is no longer adjusting
// we will have already gotten all the changes, and therefore
// don't need to do an additional paint.
rowSelectionAdjusting = false;
return;
}
rowSelectionAdjusting = isAdjusting;
// The getCellRect() calls will fail unless there is at least one column.
if (getRowCount() <= 0 || getColumnCount() <= 0) {
return;
}
int firstIndex = limit(e.getFirstIndex(), 0, getRowCount()-1);
int lastIndex = limit(e.getLastIndex(), 0, getRowCount()-1);
Rectangle firstRowRect = getCellRect(firstIndex, 0, false);
Rectangle lastRowRect = getCellRect(lastIndex, getColumnCount()-1, false);
Rectangle dirtyRegion = firstRowRect.union(lastRowRect);
repaint(dirtyRegion);
| private int | viewIndexForColumn(javax.swing.table.TableColumn aColumn)
TableColumnModel cm = getColumnModel();
for (int column = 0; column < cm.getColumnCount(); column++) {
if (cm.getColumn(column) == aColumn) {
return column;
}
}
return -1;
| private void | writeObject(java.io.ObjectOutputStream s)See readObject() and writeObject() in JComponent for more
information about serialization in Swing.
s.defaultWriteObject();
if (getUIClassID().equals(uiClassID)) {
byte count = JComponent.getWriteObjCounter(this);
JComponent.setWriteObjCounter(this, --count);
if (count == 0 && ui != null) {
ui.installUI(this);
}
}
|
|