2362N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A <code>TableColumn</code> represents all the attributes of a column in a 0N/A * <code>JTable</code>, such as width, resizibility, minimum and maximum width. 0N/A * In addition, the <code>TableColumn</code> provides slots for a renderer and 0N/A * an editor that can be used to display and edit the values in this column. 0N/A * It is also possible to specify renderers and editors on a per type basis 0N/A * rather than a per column basis - see the 0N/A * <code>setDefaultRenderer</code> method in the <code>JTable</code> class. 0N/A * This default mechanism is only used when the renderer (or 0N/A * editor) in the <code>TableColumn</code> is <code>null</code>. 0N/A * The <code>TableColumn</code> stores the link between the columns in the 0N/A * <code>JTable</code> and the columns in the <code>TableModel</code>. 0N/A * The <code>modelIndex</code> is the column in the 0N/A * <code>TableModel</code>, which will be queried for the data values for the 0N/A * cells in this column. As the column moves around in the view this 0N/A * <code>modelIndex</code> does not change. 0N/A * <b>Note:</b> Some implementations may assume that all 0N/A * <code>TableColumnModel</code>s are unique, therefore we would 0N/A * recommend that the same <code>TableColumn</code> instance 0N/A * not be added more than once to a <code>TableColumnModel</code>. 0N/A * To show <code>TableColumn</code>s with the same column of 0N/A * data from the model, create a new instance with the same 0N/A * <code>modelIndex</code>. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * @author Alan Chung 0N/A * @author Philip Milne 0N/A * @see javax.swing.table.TableColumnModel 0N/A * @see javax.swing.table.DefaultTableColumnModel 0N/A * @see javax.swing.table.JTableHeader#getDefaultRenderer() 0N/A * @see JTable#getDefaultRenderer(Class) 0N/A * @see JTable#getDefaultEditor(Class) 0N/A * @see JTable#getCellRenderer(int, int) 0N/A * @see JTable#getCellEditor(int, int) 0N/A * Obsolete as of Java 2 platform v1.3. Please use string literals to identify 0N/A * Warning: The value of this constant, "columWidth" is wrong as the 0N/A * name of the property is "columnWidth". 0N/A * Obsolete as of Java 2 platform v1.3. Please use string literals to identify 0N/A * Obsolete as of Java 2 platform v1.3. Please use string literals to identify 0N/A * Obsolete as of Java 2 platform v1.3. Please use string literals to identify 0N/A// Instance Variables 0N/A * The index of the column in the model which is to be displayed by 0N/A * this <code>TableColumn</code>. As columns are moved around in the 0N/A * view <code>modelIndex</code> remains constant. 0N/A * This object is not used internally by the drawing machinery of 0N/A * the <code>JTable</code>; identifiers may be set in the 0N/A * <code>TableColumn</code> as as an 0N/A * optional way to tag and locate table columns. The table package does 0N/A * not modify or invoke any methods in these identifier objects other 0N/A * than the <code>equals</code> method which is used in the 0N/A * <code>getColumnIndex()</code> method in the 0N/A * <code>DefaultTableColumnModel</code>. 0N/A /** The width of the column. */ 0N/A /** The minimum width of the column. */ 0N/A /** The preferred width of the column. */ 0N/A /** The maximum width of the column. */ 0N/A /** The renderer used to draw the header of the column. */ 0N/A /** The header value of the column. */ 0N/A /** The renderer used to draw the data cells of the column. */ 0N/A /** The editor used to edit the data cells of the column. */ 0N/A /** If true, the user is allowed to resize the column; the default is true. */ 0N/A * This field was not used in previous releases and there are 0N/A * currently no plans to support it in the future. 0N/A * @deprecated as of Java 2 platform v1.3 0N/A * Counter used to disable posting of resizing notifications until the 0N/A * end of the resize. 0N/A * If any <code>PropertyChangeListeners</code> have been registered, the 0N/A * <code>changeSupport</code> field describes them. 0N/A * Cover method, using a default model index of 0, 0N/A * default width of 75, a <code>null</code> renderer and a 0N/A * <code>null</code> editor. 0N/A * This method is intended for serialization. 0N/A * @see #TableColumn(int, int, TableCellRenderer, TableCellEditor) 0N/A * Cover method, using a default width of 75, a <code>null</code> 0N/A * renderer and a <code>null</code> editor. 0N/A * @see #TableColumn(int, int, TableCellRenderer, TableCellEditor) 0N/A * Cover method, using a <code>null</code> renderer and a 0N/A * <code>null</code> editor. 0N/A * @see #TableColumn(int, int, TableCellRenderer, TableCellEditor) 0N/A * Creates and initializes an instance of 0N/A * <code>TableColumn</code> with the specified model index, 0N/A * width, cell renderer, and cell editor; 0N/A * all <code>TableColumn</code> constructors delegate to this one. 0N/A * The value of <code>width</code> is used 0N/A * for both the initial and preferred width; 0N/A * if <code>width</code> is negative, 0N/A * The minimum width is set to 15 unless the initial width is less, 0N/A * in which case the minimum width is set to 0N/A * the initial width. 0N/A * When the <code>cellRenderer</code> 0N/A * or <code>cellEditor</code> parameter is <code>null</code>, 0N/A * a default value provided by the <code>JTable</code> 0N/A * <code>getDefaultRenderer</code> 0N/A * or <code>getDefaultEditor</code> method, respectively, 0N/A * provide defaults based on the type of the data in this column. 0N/A * This column-centric rendering strategy can be circumvented by overriding 0N/A * the <code>getCellRenderer</code> methods in <code>JTable</code>. 0N/A * @param modelIndex the index of the column 0N/A * in the model that supplies the data for this column in the table; 0N/A * the model index remains the same 0N/A * even when columns are reordered in the view 0N/A * @param width this column's preferred width and initial width 0N/A * @param cellRenderer the object used to render values in this column 0N/A * @param cellEditor the object used to edit values in this column 0N/A * @see #getMinWidth() 0N/A * @see JTable#getDefaultRenderer(Class) 0N/A * @see JTable#getDefaultEditor(Class) 0N/A * @see JTable#getCellRenderer(int, int) 0N/A * @see JTable#getCellEditor(int, int) 0N/A // Set other instance variables to default values. 0N/A// Modifying and Querying attributes 0N/A * Sets the model index for this column. The model index is the 0N/A * index of the column in the model that will be displayed by this 0N/A * <code>TableColumn</code>. As the <code>TableColumn</code> 0N/A * is moved around in the view the model index remains constant. 0N/A * @param modelIndex the new modelIndex 0N/A * description: The model index. 0N/A * Returns the model index for this column. 0N/A * @return the <code>modelIndex</code> property 0N/A * Sets the <code>TableColumn</code>'s identifier to 0N/A * <code>anIdentifier</code>. <p> 0N/A * Note: identifiers are not used by the <code>JTable</code>, 0N/A * convenience for the external tagging and location of columns. 0N/A * @param identifier an identifier for this column 0N/A * @see #getIdentifier 0N/A * description: A unique identifier for this column. 0N/A * Returns the <code>identifier</code> object for this column. 0N/A * Note identifiers are not used by <code>JTable</code>, 0N/A * they are purely a convenience for external use. 0N/A * If the <code>identifier</code> is <code>null</code>, 0N/A * <code>getIdentifier()</code> returns <code>getHeaderValue</code> 0N/A * @return the <code>identifier</code> property 0N/A * @see #setIdentifier 0N/A * Sets the <code>Object</code> whose string representation will be 0N/A * used as the value for the <code>headerRenderer</code>. When the 0N/A * <code>TableColumn</code> is created, the default <code>headerValue</code> 0N/A * is <code>null</code>. 0N/A * @param headerValue the new headerValue 0N/A * @see #getHeaderValue 0N/A * description: The text to be used by the header renderer. 0N/A * Returns the <code>Object</code> used as the value for the header 0N/A * @return the <code>headerValue</code> property 0N/A * @see #setHeaderValue 0N/A // Renderers and Editors 0N/A * Sets the <code>TableCellRenderer</code> used to draw the 0N/A * <code>TableColumn</code>'s header to <code>headerRenderer</code>. 0N/A * It is the header renderers responsibility to render the sorting 0N/A * indicator. If you are using sorting and specify a renderer your 0N/A * renderer must render the sorting indication. 0N/A * @param headerRenderer the new headerRenderer 0N/A * @see #getHeaderRenderer 0N/A * description: The header renderer. 0N/A * Returns the <code>TableCellRenderer</code> used to draw the header of the 0N/A * <code>TableColumn</code>. When the <code>headerRenderer</code> is 0N/A * <code>null</code>, the <code>JTableHeader</code> 0N/A * uses its <code>defaultRenderer</code>. The default value for a 0N/A * <code>headerRenderer</code> is <code>null</code>. 0N/A * @return the <code>headerRenderer</code> property 0N/A * @see #setHeaderRenderer 0N/A * @see #setHeaderValue 0N/A * @see javax.swing.table.JTableHeader#getDefaultRenderer() 0N/A * Sets the <code>TableCellRenderer</code> used by <code>JTable</code> 0N/A * to draw individual values for this column. 0N/A * @param cellRenderer the new cellRenderer 0N/A * @see #getCellRenderer 0N/A * description: The renderer to use for cell values. 0N/A * Returns the <code>TableCellRenderer</code> used by the 0N/A * <code>JTable</code> to draw 0N/A * values for this column. The <code>cellRenderer</code> of the column 0N/A * not only controls the visual look for the column, but is also used to 0N/A * interpret the value object supplied by the <code>TableModel</code>. 0N/A * When the <code>cellRenderer</code> is <code>null</code>, 0N/A * the <code>JTable</code> uses a default renderer based on the 0N/A * class of the cells in that column. The default value for a 0N/A * <code>cellRenderer</code> is <code>null</code>. 0N/A * @return the <code>cellRenderer</code> property 0N/A * @see #setCellRenderer 0N/A * @see JTable#setDefaultRenderer 0N/A * Sets the editor to used by when a cell in this column is edited. 0N/A * @param cellEditor the new cellEditor 0N/A * @see #getCellEditor 0N/A * description: The editor to use for cell values. 0N/A * Returns the <code>TableCellEditor</code> used by the 0N/A * <code>JTable</code> to edit values for this column. When the 0N/A * <code>cellEditor</code> is <code>null</code>, the <code>JTable</code> 0N/A * uses a default editor based on the 0N/A * class of the cells in that column. The default value for a 0N/A * <code>cellEditor</code> is <code>null</code>. 0N/A * @return the <code>cellEditor</code> property 0N/A * @see #setCellEditor 0N/A * @see JTable#setDefaultEditor 0N/A * This method should not be used to set the widths of columns in the 0N/A * <code>JTable</code>, use <code>setPreferredWidth</code> instead. 0N/A * Like a layout manager in the 0N/A * AWT, the <code>JTable</code> adjusts a column's width automatically 0N/A * table itself changes size, or a column's preferred width is changed. 0N/A * Setting widths programmatically therefore has no long term effect. 0N/A * This method sets this column's width to <code>width</code>. 0N/A * If <code>width</code> exceeds the minimum or maximum width, 0N/A * it is adjusted to the appropriate limiting value. 0N/A * @param width the new width 0N/A * @see #setPreferredWidth 0N/A * @see JTable#doLayout() 0N/A * description: The width of the column. 0N/A * Returns the width of the <code>TableColumn</code>. The default width is 0N/A * @return the <code>width</code> property 0N/A * Sets this column's preferred width to <code>preferredWidth</code>. 0N/A * If <code>preferredWidth</code> exceeds the minimum or maximum width, 0N/A * it is adjusted to the appropriate limiting value. 0N/A * For details on how the widths of columns in the <code>JTable</code> 0N/A * (and <code>JTableHeader</code>) are calculated from the 0N/A * <code>preferredWidth</code>, 0N/A * see the <code>doLayout</code> method in <code>JTable</code>. 0N/A * @param preferredWidth the new preferred width 0N/A * @see #getPreferredWidth 0N/A * @see JTable#doLayout() 0N/A * description: The preferred width of the column. 0N/A * Returns the preferred width of the <code>TableColumn</code>. 0N/A * The default preferred width is 75. 0N/A * @return the <code>preferredWidth</code> property 0N/A * @see #setPreferredWidth 0N/A * Sets the <code>TableColumn</code>'s minimum width to 0N/A * <code>minWidth</code>, 0N/A * adjusting the new minimum width if necessary to ensure that 0N/A * 0 <= <code>minWidth</code> <= <code>maxWidth</code>. 0N/A * For example, if the <code>minWidth</code> argument is negative, 0N/A * this method sets the <code>minWidth</code> property to 0. 0N/A * If the value of the 0N/A * <code>width</code> or <code>preferredWidth</code> property 0N/A * is less than the new minimum width, 0N/A * this method sets that property to the new minimum width. 0N/A * @param minWidth the new minimum width 0N/A * @see #setPreferredWidth 0N/A * description: The minimum width of the column. 0N/A * Returns the minimum width for the <code>TableColumn</code>. The 0N/A * <code>TableColumn</code>'s width can't be made less than this either 0N/A * by the user or programmatically. 0N/A * @return the <code>minWidth</code> property 0N/A * @see #TableColumn(int, int, TableCellRenderer, TableCellEditor) 0N/A * Sets the <code>TableColumn</code>'s maximum width to 0N/A * <code>maxWidth</code> or, 0N/A * if <code>maxWidth</code> is less than the minimum width, 0N/A * to the minimum width. 0N/A * If the value of the 0N/A * <code>width</code> or <code>preferredWidth</code> property 0N/A * is more than the new maximum width, 0N/A * this method sets that property to the new maximum width. 0N/A * @param maxWidth the new maximum width 0N/A * @see #setPreferredWidth 0N/A * description: The maximum width of the column. 0N/A * Returns the maximum width for the <code>TableColumn</code>. The 0N/A * <code>TableColumn</code>'s width can't be made larger than this 0N/A * either by the user or programmatically. The default maxWidth 0N/A * is Integer.MAX_VALUE. 0N/A * @return the <code>maxWidth</code> property 0N/A * Sets whether this column can be resized. 0N/A * @param isResizable if true, resizing is allowed; otherwise false 0N/A * @see #getResizable 0N/A * description: Whether or not this column can be resized. 0N/A * Returns true if the user is allowed to resize the 0N/A * <code>TableColumn</code>'s 0N/A * width, false otherwise. You can change the width programmatically 0N/A * regardless of this setting. The default is true. 0N/A * @return the <code>isResizable</code> property 0N/A * @see #setResizable 0N/A * Resizes the <code>TableColumn</code> to fit the width of its header cell. 0N/A * This method does nothing if the header renderer is <code>null</code> 0N/A * (the default case). Otherwise, it sets the minimum, maximum and preferred 0N/A * widths of this column to the widths of the minimum, maximum and preferred 0N/A * sizes of the Component delivered by the header renderer. 0N/A * The transient "width" property of this TableColumn is also set to the 0N/A * preferred width. Note this method is not used internally by the table 0N/A * @see #setPreferredWidth 0N/A * This field was not used in previous releases and there are 0N/A * currently no plans to support it in the future. 0N/A * @deprecated as of Java 2 platform v1.3 0N/A * This field was not used in previous releases and there are 0N/A * currently no plans to support it in the future. 0N/A * @deprecated as of Java 2 platform v1.3 0N/A// Property Change Support 0N/A * Adds a <code>PropertyChangeListener</code> to the listener list. 0N/A * The listener is registered for all properties. 0N/A * A <code>PropertyChangeEvent</code> will get fired in response to an 0N/A * explicit call to <code>setFont</code>, <code>setBackground</code>, 0N/A * or <code>setForeground</code> on the 0N/A * current component. Note that if the current component is 0N/A * inheriting its foreground, background, or font from its 0N/A * container, then no event will be fired in response to a 0N/A * change in the inherited property. 0N/A * @param listener the listener to be added 0N/A * Removes a <code>PropertyChangeListener</code> from the listener list. 0N/A * The <code>PropertyChangeListener</code> to be removed was registered 0N/A * for all properties. 0N/A * @param listener the listener to be removed 0N/A * Returns an array of all the <code>PropertyChangeListener</code>s added 0N/A * to this TableColumn with addPropertyChangeListener(). 0N/A * @return all of the <code>PropertyChangeListener</code>s added or an empty 0N/A * array if no listeners have been added 0N/A * As of Java 2 platform v1.3, this method is not called by the <code>TableColumn</code> 0N/A * constructor. Previously this method was used by the 0N/A * <code>TableColumn</code> to create a default header renderer. 0N/A * As of Java 2 platform v1.3, the default header renderer is <code>null</code>. 0N/A * <code>JTableHeader</code> now provides its own shared default 0N/A * renderer, just as the <code>JTable</code> does for its cell renderers. 0N/A * @return the default header renderer 0N/A * @see javax.swing.table.JTableHeader#createDefaultRenderer() 0N/A}
// End of class TableColumn