tablecolumn.java
来自「linux下建立JAVA虚拟机的源码KAFFE」· Java 代码 · 共 694 行 · 第 1/2 页
JAVA
694 行
/* TableColumn.java -- Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING. If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library. Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule. An independent module is a module which is not derived fromor based on this library. If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so. If you do not wish to do so, delete thisexception statement from your version. */package javax.swing.table;import java.awt.Component;import java.awt.Dimension;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.io.Serializable;import javax.swing.event.SwingPropertyChangeSupport;/** * Represents the attributes of a column in a table, including the column index, * width, minimum width, preferred width and maximum width. * * @author Andrew Selkirk */public class TableColumn implements Serializable{ static final long serialVersionUID = -6113660025878112608L; /** * The name for the <code>columnWidth</code> property (this field is * obsolete and no longer used). Note also that the typo in the value * string is deliberate, to match the specification. */ public static final String COLUMN_WIDTH_PROPERTY = "columWidth"; /** * The name for the <code>headerValue</code> property. */ public static final String HEADER_VALUE_PROPERTY = "headerValue"; /** * The name for the <code>headerRenderer</code> property. */ public static final String HEADER_RENDERER_PROPERTY = "headerRenderer"; /** * The name for the <code>cellRenderer</code> property. */ public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; /** * The index of the corresponding column in the table model. */ protected int modelIndex; /** * The identifier for the column. */ protected Object identifier; /** * The current width for the column. */ protected int width; /** * The minimum width for the column. */ protected int minWidth = 15; /** * The preferred width for the column. */ private int preferredWidth; /** * The maximum width for the column. */ protected int maxWidth = Integer.MAX_VALUE; /** * The renderer for the column header. */ protected TableCellRenderer headerRenderer; /** * The value for the column header. */ protected Object headerValue; /** * The renderer for the regular cells in this column. */ protected TableCellRenderer cellRenderer; /** * An editor for the regular cells in this column. */ protected TableCellEditor cellEditor; /** * A flag that determines whether or not the column is resizable (the default * is <code>true</code>). */ protected boolean isResizable = true; /** * resizedPostingDisableCount * * @deprecated 1.3 */ protected transient int resizedPostingDisableCount; /** * A storage and notification mechanism for property change listeners. */ private SwingPropertyChangeSupport changeSupport = new SwingPropertyChangeSupport(this); /** * Creates a new <code>TableColumn</code> that maps to column 0 in the * related table model. The default width is <code>75</code> units. */ public TableColumn() { this(0, 75, null, null); } /** * Creates a new <code>TableColumn</code> that maps to the specified column * in the related table model. The default width is <code>75</code> units. * * @param modelIndex the index of the column in the model */ public TableColumn(int modelIndex) { this(modelIndex, 75, null, null); } /** * Creates a new <code>TableColumn</code> that maps to the specified column * in the related table model, and has the specified <code>width</code>. * * @param modelIndex the index of the column in the model * @param width the width */ public TableColumn(int modelIndex, int width) { this(modelIndex, width, null, null); } /** * Creates a new <code>TableColumn</code> that maps to the specified column * in the related table model, and has the specified <code>width</code>, * <code>cellRenderer</code> and <code>cellEditor</code>. * * @param modelIndex the index of the column in the model * @param width the width * @param cellRenderer the cell renderer (<code>null</code> permitted). * @param cellEditor the cell editor (<code>null</code> permitted). */ public TableColumn(int modelIndex, int width, TableCellRenderer cellRenderer, TableCellEditor cellEditor) { this.modelIndex = modelIndex; this.width = width; this.preferredWidth = width; this.cellRenderer = cellRenderer; this.cellEditor = cellEditor; this.headerValue = null; this.identifier = null; } /** * Sets the index of the column in the related {@link TableModel} that this * <code>TableColumn</code> maps to, and sends a {@link PropertyChangeEvent} * (with the property name 'modelIndex') to all registered listeners. * * @param modelIndex the column index in the model. * * @see #getModelIndex() */ public void setModelIndex(int modelIndex) { if (this.modelIndex != modelIndex) { int oldValue = this.modelIndex; this.modelIndex = modelIndex; changeSupport.firePropertyChange("modelIndex", oldValue, modelIndex); } } /** * Returns the index of the column in the related {@link TableModel} that * this <code>TableColumn</code> maps to. * * @return the model index. * * @see #setModelIndex(int) */ public int getModelIndex() { return modelIndex; } /** * Sets the identifier for the column and sends a {@link PropertyChangeEvent} * (with the property name 'identifier') to all registered listeners. * * @param identifier the identifier (<code>null</code> permitted). * * @see #getIdentifier() */ public void setIdentifier(Object identifier) { if (this.identifier != identifier) { Object oldValue = this.identifier; this.identifier = identifier; changeSupport.firePropertyChange("identifier", oldValue, identifier); } } /** * Returns the identifier for the column, or {@link #getHeaderValue()} if the * identifier is <code>null</code>. * * @return The identifier (or {@link #getHeaderValue()} if the identifier is * <code>null</code>). */ public Object getIdentifier() { if (identifier == null) return getHeaderValue(); return identifier; } /** * Sets the header value and sends a {@link PropertyChangeEvent} (with the * property name {@link #HEADER_VALUE_PROPERTY}) to all registered listeners. * * @param headerValue the value of the header (<code>null</code> permitted). * * @see #getHeaderValue() */ public void setHeaderValue(Object headerValue) { if (this.headerValue == headerValue) return; Object oldValue = this.headerValue; this.headerValue = headerValue; changeSupport.firePropertyChange(HEADER_VALUE_PROPERTY, oldValue, headerValue); } /** * Returns the header value. * * @return the value of the header. * * @see #getHeaderValue() */ public Object getHeaderValue() { return headerValue; } /** * Sets the renderer for the column header and sends a * {@link PropertyChangeEvent} (with the property name * {@link #HEADER_RENDERER_PROPERTY}) to all registered listeners. * * @param renderer the header renderer (<code>null</code> permitted). * * @see #getHeaderRenderer() */ public void setHeaderRenderer(TableCellRenderer renderer) { if (headerRenderer == renderer) return; TableCellRenderer oldRenderer = headerRenderer; headerRenderer = renderer; changeSupport.firePropertyChange(HEADER_RENDERER_PROPERTY, oldRenderer, headerRenderer); } /** * Returns the renderer for the column header. * * @return The renderer for the column header (possibly <code>null</code>). * * @see #setHeaderRenderer(TableCellRenderer) */ public TableCellRenderer getHeaderRenderer() { return headerRenderer; } /** * Sets the renderer for cells in this column and sends a * {@link PropertyChangeEvent} (with the property name * {@link #CELL_RENDERER_PROPERTY}) to all registered listeners. * * @param renderer the cell renderer (<code>null</code> permitted). * * @see #getCellRenderer() */ public void setCellRenderer(TableCellRenderer renderer) { if (cellRenderer == renderer) return; TableCellRenderer oldRenderer = cellRenderer; cellRenderer = renderer;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?