| 
JavaTM 2 Platform Standard Ed. 6  | 
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.table.DefaultTableColumnModel
public class DefaultTableColumnModel
JTable 的标准列处理程序。
 
警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前的序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder。
JTable| 字段摘要 | |
|---|---|
protected  ChangeEvent | 
changeEvent
更改事件(只需要一个)  | 
protected  int | 
columnMargin
每列之间的空白宽度  | 
protected  boolean | 
columnSelectionAllowed
此列模型中允许的列选择  | 
protected  EventListenerList | 
listenerList
TableColumnModelListener 的列表  | 
protected  ListSelectionModel | 
selectionModel
跟踪列选择的模型  | 
protected  Vector<TableColumn> | 
tableColumns
此模型中 TableColumn 对象组成的数组  | 
protected  int | 
totalColumnWidth
所有列总宽度的本地缓存  | 
| 构造方法摘要 | |
|---|---|
DefaultTableColumnModel()
创建默认的表列模型。  | 
|
| 方法摘要 | ||
|---|---|---|
 void | 
addColumn(TableColumn aColumn)
将 aColumn 追加到 tableColumns 数组的结尾。 | 
|
 void | 
addColumnModelListener(TableColumnModelListener x)
添加表列模型事件的侦听器。  | 
|
protected  ListSelectionModel | 
createSelectionModel()
创建新的默认列表选择模型。  | 
|
protected  void | 
fireColumnAdded(TableColumnModelEvent e)
通知所有对此事件类型的通知感兴趣的已注册侦听器。  | 
|
protected  void | 
fireColumnMarginChanged()
通知所有对此事件类型的通知感兴趣的已注册侦听器。  | 
|
protected  void | 
fireColumnMoved(TableColumnModelEvent e)
通知所有对此事件类型的通知感兴趣的已注册侦听器。  | 
|
protected  void | 
fireColumnRemoved(TableColumnModelEvent e)
通知所有对此事件类型的通知感兴趣的已注册侦听器。  | 
|
protected  void | 
fireColumnSelectionChanged(ListSelectionEvent e)
通知所有对此事件类型的通知感兴趣的已注册侦听器。  | 
|
 TableColumn | 
getColumn(int columnIndex)
返回 columnIndex 处列的 TableColumn 对象。 | 
|
 int | 
getColumnCount()
返回 tableColumns 数组中的列数。 | 
|
 int | 
getColumnIndex(Object identifier)
返回 tableColumns 数组中第一列的索引,当使用 equals 进行比较时,该列的标识符等于 identifier。 | 
|
 int | 
getColumnIndexAtX(int x)
返回位于 x 处列的索引,如果该点处没有列,则返回 -1。 | 
|
 int | 
getColumnMargin()
返回 TableColumn 的空白宽度。 | 
|
 TableColumnModelListener[] | 
getColumnModelListeners()
返回一个包含在此模型上注册的所有列模型侦听器的数组。  | 
|
 Enumeration<TableColumn> | 
getColumns()
返回该模型中所有列的一个 Enumeration。 | 
|
 boolean | 
getColumnSelectionAllowed()
如果允许列选择,则返回 true,否则返回 false。  | 
|
 | 
getListeners(Class<T> listenerType)
返回当前已在此模型上注册为 FooListener 的所有对象组成的数组。 | 
|
 int | 
getSelectedColumnCount()
返回选定的列数。  | 
|
 int[] | 
getSelectedColumns()
返回包含选定列的数组。  | 
|
 ListSelectionModel | 
getSelectionModel()
返回用来维护列选择状态的 ListSelectionModel。 | 
|
 int | 
getTotalColumnWidth()
返回所有列的总宽度。  | 
|
 void | 
moveColumn(int columnIndex,
           int newIndex)
将 columnIndex 位置的列和标题移到 newIndex。 | 
|
 void | 
propertyChange(PropertyChangeEvent evt)
Property Change Listener 更改方法。  | 
|
protected  void | 
recalcWidthCache()
重新计算所有列的总宽度。  | 
|
 void | 
removeColumn(TableColumn column)
从 tableColumns 数组删除 column。 | 
|
 void | 
removeColumnModelListener(TableColumnModelListener x)
移除表列模型事件的侦听器。  | 
|
 void | 
setColumnMargin(int newMargin)
将列空白设置为 newMargin。 | 
|
 void | 
setColumnSelectionAllowed(boolean flag)
设置是否允许列选择。  | 
|
 void | 
setSelectionModel(ListSelectionModel newModel)
将此 TableColumnModel 的选择模型设置为 newModel,并为来自新选择模型的侦听器通知注册它。 | 
|
 void | 
valueChanged(ListSelectionEvent e)
列选择更改时转发 ListSelectionEvents 的 ListSelectionListener。 | 
|
| 从类 java.lang.Object 继承的方法 | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| 字段详细信息 | 
|---|
protected Vector<TableColumn> tableColumns
protected ListSelectionModel selectionModel
protected int columnMargin
protected EventListenerList listenerList
protected transient ChangeEvent changeEvent
protected boolean columnSelectionAllowed
protected int totalColumnWidth
| 构造方法详细信息 | 
|---|
public DefaultTableColumnModel()
| 方法详细信息 | 
|---|
public void addColumn(TableColumn aColumn)
aColumn 追加到 tableColumns 数组的结尾。此方法还将 columnAdded 事件发送到它的侦听器。
TableColumnModel 中的 addColumnaColumn - 要添加的 TableColumn
IllegalArgumentException - 如果 aColumn 为 nullremoveColumn(javax.swing.table.TableColumn)public void removeColumn(TableColumn column)
tableColumns 数组删除 column。如果 column 不在该表各列的列表中,则此方法不执行任何操作。此方法调用 tile 重新调整标题和表视图的大小。此方法还将 columnRemoved 事件发送到它的侦听器。
TableColumnModel 中的 removeColumncolumn - 要移除的 TableColumnaddColumn(javax.swing.table.TableColumn)
public void moveColumn(int columnIndex,
                       int newIndex)
columnIndex 位置的列和标题移到 newIndex。原来在 columnIndex 位置的列现在可以在 newIndex 处找到。newIndex 位置上的原有列向左或右移动以留出空间。如果 columnIndex 等于 newIndex,则此操作不移动任何列。此方法还将 columnMoved 事件发送到它的侦听器。
TableColumnModel 中的 moveColumncolumnIndex - 要移动列的索引newIndex - 将列移动到该新索引位置
IllegalArgumentException - 如果 column 或 newIndex 不在有效范围内public void setColumnMargin(int newMargin)
newMargin。此方法还将 columnMarginChanged 事件发送到它的侦听器。
TableColumnModel 中的 setColumnMarginnewMargin - 新的空白宽度,以像素为单位getColumnMargin(), 
getTotalColumnWidth()public int getColumnCount()
tableColumns 数组中的列数。
TableColumnModel 中的 getColumnCounttableColumns 数组中的列数getColumns()public Enumeration<TableColumn> getColumns()
Enumeration。
TableColumnModel 中的 getColumnsEnumerationpublic int getColumnIndex(Object identifier)
tableColumns 数组中第一列的索引,当使用 equals 进行比较时,该列的标识符等于 identifier。
TableColumnModel 中的 getColumnIndexidentifier - 标识符对象
tableColumns 数组中第一列的索引,该列的标识符等于 identifier
IllegalArgumentException - 如果 identifier 为 null,或者没有 TableColumn 具有此 identifiergetColumn(int)public TableColumn getColumn(int columnIndex)
columnIndex 处列的 TableColumn 对象。
TableColumnModel 中的 getColumncolumnIndex - 所需列的索引
columnIndex 处列的 TableColumn 对象public int getColumnMargin()
TableColumn 的空白宽度。默认的 columnMargin 为 1。
TableColumnModel 中的 getColumnMarginTableColumn 的最大宽度setColumnMargin(int)public int getColumnIndexAtX(int x)
x 处列的索引,如果该点处没有列,则返回 -1。
为了与 Swing 的可分离模型架构保持一致,TableColumnModel 不知道表的各列是如何实际显示在屏幕上的。各列的可视化表示由使用此模型的视图/控制器(通常是 JTable)来负责。该视图/控制器无需从左到右按顺序显示各列。例如,为了适应语言环境的优先选择,可以从右到左显示各列,或者可能根据用户的请求隐藏某些列。因为模型不知道各列是如何在屏幕上布局的,所以不应将给定的 xPosition 认为是 2D 图形空间中的坐标。相反,应该将其认为是从模型中首列开始的一个宽度。如果需要 2D 空间中给定 X 坐标的列索引,则可以使用 JTable.columnAtPoint。
TableColumnModel 中的 getColumnIndexAtXx - 需要的水平位置
JTable.columnAtPoint(java.awt.Point)public int getTotalColumnWidth()
TableColumnModel 中的 getTotalColumnWidthtotalColumnWidth 属性public void setSelectionModel(ListSelectionModel newModel)
TableColumnModel 的选择模型设置为 newModel,并为来自新选择模型的侦听器通知注册它。如果 newModel 为 null,则抛出一个异常。
TableColumnModel 中的 setSelectionModelnewModel - 新的选择模型
IllegalArgumentException - 如果 newModel 为 nullgetSelectionModel()public ListSelectionModel getSelectionModel()
ListSelectionModel。
TableColumnModel 中的 getSelectionModelnull。setSelectionModel(javax.swing.ListSelectionModel)public void setColumnSelectionAllowed(boolean flag)
TableColumnModel 中的 setColumnSelectionAllowedflag - 如果允许列选择,则为 true,否则为 falseTableColumnModel.getColumnSelectionAllowed()public boolean getColumnSelectionAllowed()
TableColumnModel 中的 getColumnSelectionAllowedcolumnSelectionAllowed 属性TableColumnModel.setColumnSelectionAllowed(boolean)public int[] getSelectedColumns()
selectionModel 为 null,则返回一个空数组。
TableColumnModel 中的 getSelectedColumnsselectionModel 为 null,则返回一个空数组public int getSelectedColumnCount()
TableColumnModel 中的 getSelectedColumnCountpublic void addColumnModelListener(TableColumnModelListener x)
TableColumnModel 中的 addColumnModelListenerx - 一个 TableColumnModelListener 对象public void removeColumnModelListener(TableColumnModelListener x)
TableColumnModel 中的 removeColumnModelListenerx - 一个 TableColumnModelListener 对象public TableColumnModelListener[] getColumnModelListeners()
ColumnModelListener,如果当前没有已注册的列模型侦听器,则返回一个空数组addColumnModelListener(javax.swing.event.TableColumnModelListener), 
removeColumnModelListener(javax.swing.event.TableColumnModelListener)protected void fireColumnAdded(TableColumnModelEvent e)
e - 接收的事件EventListenerListprotected void fireColumnRemoved(TableColumnModelEvent e)
e - 接收的事件EventListenerListprotected void fireColumnMoved(TableColumnModelEvent e)
e - 接收的事件EventListenerListprotected void fireColumnSelectionChanged(ListSelectionEvent e)
e - 接收的事件EventListenerListprotected void fireColumnMarginChanged()
EventListenerListpublic <T extends EventListener> T[] getListeners(Class<T> listenerType)
FooListener 的所有对象组成的数组。FooListener 是用 addFooListener 方法注册的。
 
可以使用 class 字面值(如 FooListener.class)来指定 listenerType 参数。例如,可以使用以下代码查询 DefaultTableColumnModel m 的列模型侦听器:
 
ColumnModelListener[] cmls = (ColumnModelListener[])(m.getListeners(ColumnModelListener.class));如果不存在这样的侦听器,则此方法将返回一个空数组。
listenerType - 请求的侦听器类型;此参数应该指定一个从 java.util.EventListener 继承的接口
FooListener 的所有对象组成的数组,如果没有添加这样的侦听器,则返回一个空数组
ClassCastException - 如果 listenerType 未指定实现 java.util.EventListener 的类或接口。getColumnModelListeners()public void propertyChange(PropertyChangeEvent evt)
PropertyChangeListener 中的 propertyChangeevt - PropertyChangeEventpublic void valueChanged(ListSelectionEvent e)
ListSelectionEvents 的 ListSelectionListener。
ListSelectionListener 中的 valueChangede - 更改事件protected ListSelectionModel createSelectionModel()
protected void recalcWidthCache()
totalColumnWidth 属性。
  | 
JavaTM 2 Platform Standard Ed. 6  | 
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only。