| 
 | JavaTM 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 | listenerListTableColumnModelListener 的列表 | 
| 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 中的 
      addColumn
     aColumn - 要添加的 
      TableColumn 
     IllegalArgumentException - 如果 
      aColumn 为 
      null
     removeColumn(javax.swing.table.TableColumn)
     public void removeColumn(TableColumn column)
tableColumns 数组删除 
    column。如果 
    column 不在该表各列的列表中,则此方法不执行任何操作。此方法调用 
    tile 重新调整标题和表视图的大小。此方法还将 
    columnRemoved 事件发送到它的侦听器。 
    
TableColumnModel 中的 
      removeColumn
     column - 要移除的 
      TableColumn
     addColumn(javax.swing.table.TableColumn)
     
public void moveColumn(int columnIndex,
                       int newIndex) 
  columnIndex 位置的列和标题移到 
    newIndex。原来在 
    columnIndex 位置的列现在可以在 
    newIndex 处找到。
    newIndex 位置上的原有列向左或右移动以留出空间。如果 
    columnIndex 等于 
    newIndex,则此操作不移动任何列。此方法还将 
    columnMoved 事件发送到它的侦听器。 
    
TableColumnModel 中的 
      moveColumn
     columnIndex - 要移动列的索引
     newIndex - 将列移动到该新索引位置 
     IllegalArgumentException - 如果 
      column 或 
      newIndex 不在有效范围内
     public void setColumnMargin(int newMargin)
newMargin。此方法还将 
    columnMarginChanged 事件发送到它的侦听器。 
    
TableColumnModel 中的 
      setColumnMargin
     newMargin - 新的空白宽度,以像素为单位
     getColumnMargin(), 
      getTotalColumnWidth()
     public int getColumnCount()
tableColumns 数组中的列数。 
    
TableColumnModel 中的 
      getColumnCount
     tableColumns 数组中的列数
     getColumns()
     public Enumeration<TableColumn> getColumns()
Enumeration。 
    
TableColumnModel 中的 
      getColumns
     Enumeration
     public int getColumnIndex(Object identifier)
tableColumns 数组中第一列的索引,当使用 
    equals 进行比较时,该列的标识符等于 
    identifier。 
    
TableColumnModel 中的 
      getColumnIndex
     identifier - 标识符对象 
     tableColumns 数组中第一列的索引,该列的标识符等于 
      identifier 
     IllegalArgumentException - 如果 
      identifier 为 
      null,或者没有 
      TableColumn 具有此 
      identifier
     getColumn(int)
     public TableColumn getColumn(int columnIndex)
columnIndex 处列的 
    TableColumn 对象。 
    
TableColumnModel 中的 
      getColumn
     columnIndex - 所需列的索引 
     columnIndex 处列的 
      TableColumn 对象
     public int getColumnMargin()
TableColumn 的空白宽度。默认的 
    columnMargin 为 1。 
    
TableColumnModel 中的 
      getColumnMargin
     TableColumn 的最大宽度
     setColumnMargin(int)
     public int getColumnIndexAtX(int x)
x 处列的索引,如果该点处没有列,则返回 -1。 为了与 Swing 的可分离模型架构保持一致,TableColumnModel 不知道表的各列是如何实际显示在屏幕上的。各列的可视化表示由使用此模型的视图/控制器(通常是 JTable)来负责。该视图/控制器无需从左到右按顺序显示各列。例如,为了适应语言环境的优先选择,可以从右到左显示各列,或者可能根据用户的请求隐藏某些列。因为模型不知道各列是如何在屏幕上布局的,所以不应将给定的 
    xPosition 认为是 2D 图形空间中的坐标。相反,应该将其认为是从模型中首列开始的一个宽度。如果需要 2D 空间中给定 X 坐标的列索引,则可以使用 
    JTable.columnAtPoint。 
    
TableColumnModel 中的 
      getColumnIndexAtX
     x - 需要的水平位置 
     JTable.columnAtPoint(java.awt.Point)
     public int getTotalColumnWidth()
TableColumnModel 中的 
      getTotalColumnWidth
     totalColumnWidth 属性
     public void setSelectionModel(ListSelectionModel newModel)
TableColumnModel 的选择模型设置为 
    newModel,并为来自新选择模型的侦听器通知注册它。如果 
    newModel 为 
    null,则抛出一个异常。 
    
TableColumnModel 中的 
      setSelectionModel
     newModel - 新的选择模型 
     IllegalArgumentException - 如果 
      newModel 为 
      null
     getSelectionModel()
     public ListSelectionModel getSelectionModel()
ListSelectionModel。 
    
TableColumnModel 中的 
      getSelectionModel
     null。
     setSelectionModel(javax.swing.ListSelectionModel)
     public void setColumnSelectionAllowed(boolean flag)
TableColumnModel 中的 
      setColumnSelectionAllowed
     flag - 如果允许列选择,则为 true,否则为 false
     TableColumnModel.getColumnSelectionAllowed()
     public boolean getColumnSelectionAllowed()
TableColumnModel 中的 
      getColumnSelectionAllowed
     columnSelectionAllowed 属性
     TableColumnModel.setColumnSelectionAllowed(boolean)
     public int[] getSelectedColumns()
selectionModel 为 
    null,则返回一个空数组。 
    
TableColumnModel 中的 
      getSelectedColumns
     selectionModel 为 
      null,则返回一个空数组
     public int getSelectedColumnCount()
TableColumnModel 中的 
      getSelectedColumnCount
     public void addColumnModelListener(TableColumnModelListener x)
TableColumnModel 中的 
      addColumnModelListener
     x - 一个 
      TableColumnModelListener 对象
     public void removeColumnModelListener(TableColumnModelListener x)
TableColumnModel 中的 
      removeColumnModelListener
     x - 一个 
      TableColumnModelListener 对象
     public TableColumnModelListener[] getColumnModelListeners()
ColumnModelListener,如果当前没有已注册的列模型侦听器,则返回一个空数组
     addColumnModelListener(javax.swing.event.TableColumnModelListener), 
      removeColumnModelListener(javax.swing.event.TableColumnModelListener)
     protected void fireColumnAdded(TableColumnModelEvent e)
e - 接收的事件
     EventListenerList
     protected void fireColumnRemoved(TableColumnModelEvent e)
e - 接收的事件
     EventListenerList
     protected void fireColumnMoved(TableColumnModelEvent e)
e - 接收的事件
     EventListenerList
     protected void fireColumnSelectionChanged(ListSelectionEvent e)
e - 接收的事件
     EventListenerList
     protected void fireColumnMarginChanged()
EventListenerList
     public <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 中的 
      propertyChange
     evt - 
      PropertyChangeEvent
     public void valueChanged(ListSelectionEvent e)
ListSelectionEvents 的 
    ListSelectionListener。 
    
ListSelectionListener 中的 
      valueChanged
     e - 更改事件
     protected ListSelectionModel createSelectionModel()
protected void recalcWidthCache()
totalColumnWidth 属性。 
    
| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。