< prev index next >
src/java.desktop/share/classes/javax/swing/table/DefaultTableColumnModel.java
Print this page
@@ -35,19 +35,19 @@
import java.beans.PropertyChangeEvent;
import java.io.Serializable;
import sun.swing.SwingUtilities2;
/**
- * The standard column-handler for a <code>JTable</code>.
+ * The standard column-handler for a {@code JTable}.
* <p>
* <strong>Warning:</strong>
* 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 JavaBeans™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Alan Chung
* @author Philip Milne
* @see JTable
@@ -101,18 +101,18 @@
//
// Modifying the model
//
/**
- * Appends <code>aColumn</code> to the end of the
- * <code>tableColumns</code> array.
- * This method also posts the <code>columnAdded</code>
+ * Appends {@code aColumn} to the end of the
+ * {@code tableColumns} array.
+ * This method also posts the {@code columnAdded}
* event to its listeners.
*
- * @param aColumn the <code>TableColumn</code> to be added
- * @exception IllegalArgumentException if <code>aColumn</code> is
- * <code>null</code>
+ * @param aColumn the {@code TableColumn} to be added
+ * @exception IllegalArgumentException if {@code aColumn} is
+ * {@code null}
* @see #removeColumn
*/
public void addColumn(TableColumn aColumn) {
if (aColumn == null) {
throw new IllegalArgumentException("Object is null");
@@ -126,19 +126,19 @@
fireColumnAdded(new TableColumnModelEvent(this, 0,
getColumnCount() - 1));
}
/**
- * Deletes the <code>column</code> from the
- * <code>tableColumns</code> array. This method will do nothing if
- * <code>column</code> is not in the table's columns list.
- * <code>tile</code> is called
+ * Deletes the {@code column} from the
+ * {@code tableColumns} array. This method will do nothing if
+ * {@code column} is not in the table's columns list.
+ * {@code tile} is called
* to resize both the header and table views.
- * This method also posts a <code>columnRemoved</code>
+ * This method also posts a {@code columnRemoved}
* event to its listeners.
*
- * @param column the <code>TableColumn</code> to be removed
+ * @param column the {@code TableColumn} to be removed
* @see #addColumn
*/
public void removeColumn(TableColumn column) {
int columnIndex = tableColumns.indexOf(column);
@@ -158,22 +158,22 @@
columnIndex, 0));
}
}
/**
- * Moves the column and heading at <code>columnIndex</code> to
- * <code>newIndex</code>. The old column at <code>columnIndex</code>
- * will now be found at <code>newIndex</code>. The column
- * that used to be at <code>newIndex</code> is shifted
+ * Moves the column and heading at {@code columnIndex} to
+ * {@code newIndex}. The old column at {@code columnIndex}
+ * will now be found at {@code newIndex}. The column
+ * that used to be at {@code newIndex} is shifted
* left or right to make room. This will not move any columns if
- * <code>columnIndex</code> equals <code>newIndex</code>. This method
- * also posts a <code>columnMoved</code> event to its listeners.
+ * {@code columnIndex} equals {@code newIndex}. This method
+ * also posts a {@code columnMoved} event to its listeners.
*
* @param columnIndex the index of column to be moved
* @param newIndex new index to move the column
- * @exception IllegalArgumentException if <code>column</code> or
- * <code>newIndex</code>
+ * @exception IllegalArgumentException if {@code column} or
+ * {@code newIndex}
* are not in the valid range
*/
public void moveColumn(int columnIndex, int newIndex) {
if ((columnIndex < 0) || (columnIndex >= getColumnCount()) ||
(newIndex < 0) || (newIndex >= getColumnCount()))
@@ -209,12 +209,12 @@
fireColumnMoved(new TableColumnModelEvent(this, columnIndex,
newIndex));
}
/**
- * Sets the column margin to <code>newMargin</code>. This method
- * also posts a <code>columnMarginChanged</code> event to its
+ * Sets the column margin to {@code newMargin}. This method
+ * also posts a {@code columnMarginChanged} event to its
* listeners.
*
* @param newMargin the new margin width, in pixels
* @see #getColumnMargin
* @see #getTotalColumnWidth
@@ -230,40 +230,40 @@
//
// Querying the model
//
/**
- * Returns the number of columns in the <code>tableColumns</code> array.
+ * Returns the number of columns in the {@code tableColumns} array.
*
- * @return the number of columns in the <code>tableColumns</code> array
+ * @return the number of columns in the {@code tableColumns} array
* @see #getColumns
*/
public int getColumnCount() {
return tableColumns.size();
}
/**
- * Returns an <code>Enumeration</code> of all the columns in the model.
- * @return an <code>Enumeration</code> of the columns in the model
+ * Returns an {@code Enumeration} of all the columns in the model.
+ * @return an {@code Enumeration} of the columns in the model
*/
public Enumeration<TableColumn> getColumns() {
return tableColumns.elements();
}
/**
- * Returns the index of the first column in the <code>tableColumns</code>
- * array whose identifier is equal to <code>identifier</code>,
- * when compared using <code>equals</code>.
+ * Returns the index of the first column in the {@code tableColumns}
+ * array whose identifier is equal to {@code identifier},
+ * when compared using {@code equals}.
*
* @param identifier the identifier object
* @return the index of the first column in the
- * <code>tableColumns</code> array whose identifier
- * is equal to <code>identifier</code>
- * @exception IllegalArgumentException if <code>identifier</code>
- * is <code>null</code>, or if no
- * <code>TableColumn</code> has this
- * <code>identifier</code>
+ * {@code tableColumns} array whose identifier
+ * is equal to {@code identifier}
+ * @exception IllegalArgumentException if {@code identifier}
+ * is {@code null}, or if no
+ * {@code TableColumn} has this
+ * {@code identifier}
* @see #getColumn
*/
public int getColumnIndex(Object identifier) {
if (identifier == null) {
throw new IllegalArgumentException("Identifier is null");
@@ -282,49 +282,49 @@
}
throw new IllegalArgumentException("Identifier not found");
}
/**
- * Returns the <code>TableColumn</code> object for the column
- * at <code>columnIndex</code>.
+ * Returns the {@code TableColumn} object for the column
+ * at {@code columnIndex}.
*
* @param columnIndex the index of the column desired
- * @return the <code>TableColumn</code> object for the column
- * at <code>columnIndex</code>
+ * @return the {@code TableColumn} object for the column
+ * at {@code columnIndex}
*/
public TableColumn getColumn(int columnIndex) {
return tableColumns.elementAt(columnIndex);
}
/**
- * Returns the width margin for <code>TableColumn</code>.
- * The default <code>columnMargin</code> is 1.
+ * Returns the width margin for {@code TableColumn}.
+ * The default {@code columnMargin} is 1.
*
- * @return the maximum width for the <code>TableColumn</code>
+ * @return the maximum width for the {@code TableColumn}
* @see #setColumnMargin
*/
public int getColumnMargin() {
return columnMargin;
}
/**
- * Returns the index of the column that lies at position <code>x</code>,
+ * Returns the index of the column that lies at position {@code x},
* or -1 if no column covers this point.
*
* In keeping with Swing's separable model architecture, a
* TableColumnModel does not know how the table columns actually appear on
* screen. The visual presentation of the columns is the responsibility
* of the view/controller object using this model (typically JTable). The
* view/controller need not display the columns sequentially from left to
* right. For example, columns could be displayed from right to left to
* accommodate a locale preference or some columns might be hidden at the
* request of the user. Because the model does not know how the columns
- * are laid out on screen, the given <code>xPosition</code> should not be
+ * are laid out on screen, the given {@code xPosition} should not be
* considered to be a coordinate in 2D graphics space. Instead, it should
* be considered to be a width from the start of the first column in the
* model. If the column index for a given X coordinate in 2D space is
- * required, <code>JTable.columnAtPoint</code> can be used instead.
+ * required, {@code JTable.columnAtPoint} can be used instead.
*
* @param x the horizontal location of interest
* @return the index of the column or -1 if no column is found
* @see javax.swing.JTable#columnAtPoint
*/
@@ -342,11 +342,11 @@
return -1;
}
/**
* Returns the total combined width of all columns.
- * @return the <code>totalColumnWidth</code> property
+ * @return the {@code totalColumnWidth} property
*/
public int getTotalColumnWidth() {
if (totalColumnWidth == -1) {
recalcWidthCache();
}
@@ -356,19 +356,19 @@
//
// Selection model
//
/**
- * Sets the selection model for this <code>TableColumnModel</code>
- * to <code>newModel</code>
+ * Sets the selection model for this {@code TableColumnModel}
+ * to {@code newModel}
* and registers for listener notifications from the new selection
- * model. If <code>newModel</code> is <code>null</code>,
+ * model. If {@code newModel} is {@code null},
* an exception is thrown.
*
* @param newModel the new selection model
- * @exception IllegalArgumentException if <code>newModel</code>
- * is <code>null</code>
+ * @exception IllegalArgumentException if {@code newModel}
+ * is {@code null}
* @see #getSelectionModel
*/
public void setSelectionModel(ListSelectionModel newModel) {
if (newModel == null) {
throw new IllegalArgumentException("Cannot set a null SelectionModel");
@@ -385,15 +385,15 @@
newModel.addListSelectionListener(this);
}
}
/**
- * Returns the <code>ListSelectionModel</code> that is used to
+ * Returns the {@code ListSelectionModel} that is used to
* maintain column selection state.
*
* @return the object that provides column selection state. Or
- * <code>null</code> if row selection is not allowed.
+ * {@code null} if row selection is not allowed.
* @see #setSelectionModel
*/
public ListSelectionModel getSelectionModel() {
return selectionModel;
}
@@ -409,23 +409,23 @@
// implements javax.swing.table.TableColumnModel
/**
* Returns true if column selection is allowed, otherwise false.
* The default is false.
- * @return the <code>columnSelectionAllowed</code> property
+ * @return the {@code columnSelectionAllowed} property
*/
public boolean getColumnSelectionAllowed() {
return columnSelectionAllowed;
}
// implements javax.swing.table.TableColumnModel
/**
- * Returns an array of selected columns. If <code>selectionModel</code>
- * is <code>null</code>, returns an empty array.
+ * Returns an array of selected columns. If {@code selectionModel}
+ * is {@code null}, returns an empty array.
* @return an array of selected columns or an empty array if nothing
- * is selected or the <code>selectionModel</code> is
- * <code>null</code>
+ * is selected or the {@code selectionModel} is
+ * {@code null}
*/
public int[] getSelectedColumns() {
if (selectionModel != null) {
int iMin = selectionModel.getMinSelectionIndex();
int iMax = selectionModel.getMaxSelectionIndex();
@@ -474,30 +474,30 @@
//
// implements javax.swing.table.TableColumnModel
/**
* Adds a listener for table column model events.
- * @param x a <code>TableColumnModelListener</code> object
+ * @param x a {@code TableColumnModelListener} object
*/
public void addColumnModelListener(TableColumnModelListener x) {
listenerList.add(TableColumnModelListener.class, x);
}
// implements javax.swing.table.TableColumnModel
/**
* Removes a listener for table column model events.
- * @param x a <code>TableColumnModelListener</code> object
+ * @param x a {@code TableColumnModelListener} object
*/
public void removeColumnModelListener(TableColumnModelListener x) {
listenerList.remove(TableColumnModelListener.class, x);
}
/**
* Returns an array of all the column model listeners
* registered on this model.
*
- * @return all of this default table column model's <code>ColumnModelListener</code>s
+ * @return all of this default table column model's {@code ColumnModelListener}s
* or an empty
* array if no column model listeners are currently registered
*
* @see #addColumnModelListener
* @see #removeColumnModelListener
@@ -638,16 +638,16 @@
* <code><em>Foo</em>Listener</code>s are registered using the
* <code>add<em>Foo</em>Listener</code> method.
*
* <p>
*
- * You can specify the <code>listenerType</code> argument
+ * You can specify the {@code listenerType} argument
* with a class literal,
* such as
* <code><em>Foo</em>Listener.class</code>.
* For example, you can query a
- * <code>DefaultTableColumnModel</code> <code>m</code>
+ * {@code DefaultTableColumnModel m}
* for its column model listeners with the following code:
*
* <pre>ColumnModelListener[] cmls = (ColumnModelListener[])(m.getListeners(ColumnModelListener.class));</pre>
*
* If no such listeners exist, this method returns an empty array.
@@ -656,13 +656,13 @@
* @param listenerType the type of listeners requested
* @return an array of all objects registered as
* <code><em>Foo</em>Listener</code>s on this model,
* or an empty array if no such
* listeners have been added
- * @exception ClassCastException if <code>listenerType</code>
+ * @exception ClassCastException if {@code listenerType}
* doesn't specify a class or interface that implements
- * <code>java.util.EventListener</code>
+ * {@code java.util.EventListener}
*
* @see #getColumnModelListeners
* @since 1.3
*/
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
@@ -677,11 +677,11 @@
// implements java.beans.PropertyChangeListener
/**
* Property Change Listener change method. Used to track changes
* to the column width or preferred column width.
*
- * @param evt <code>PropertyChangeEvent</code>
+ * @param evt {@code PropertyChangeEvent}
*/
public void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
if (name == "width" || name == "preferredWidth") {
@@ -697,12 +697,12 @@
// Implementing ListSelectionListener interface
//
// implements javax.swing.event.ListSelectionListener
/**
- * A <code>ListSelectionListener</code> that forwards
- * <code>ListSelectionEvents</code> when there is a column
+ * A {@code ListSelectionListener} that forwards
+ * {@code ListSelectionEvents} when there is a column
* selection change.
*
* @param e the change event
*/
public void valueChanged(ListSelectionEvent e) {
@@ -722,11 +722,11 @@
return new DefaultListSelectionModel();
}
/**
* Recalculates the total combined width of all columns. Updates the
- * <code>totalColumnWidth</code> property.
+ * {@code totalColumnWidth} property.
*/
protected void recalcWidthCache() {
Enumeration<TableColumn> enumeration = getColumns();
totalColumnWidth = 0;
while (enumeration.hasMoreElements()) {
< prev index next >