所有类


javax.swing.event
类 TableModelEvent

java.lang.Object
  继承者 java.util.EventObject
      继承者 javax.swing.event.TableModelEvent
所有已实现的接口:
Serializable

public class TableModelEvent
   
   
   
   
   
extends EventObject

TableModelEvent 用于通知侦听器某一表模型已发生更改。模型事件描述 TableModel 的更改,并且对行和列的所有引用都在该模型的坐标系统中。可以根据构造方法中使用的参数,用 TableModelevent 指定以下更改类型:

 TableModelEvent(source);              //  The data, ie. all rows changed 
 TableModelEvent(source, HEADER_ROW);  //  Structure change, reallocate TableColumns
 TableModelEvent(source, 1);           //  Row 1 changed
 TableModelEvent(source, 3, 6);        //  Rows 3 to 6 inclusive changed
 TableModelEvent(source, 2, 2, 6);     //  Cell at (2, 6) changed
 TableModelEvent(source, 3, 6, ALL_COLUMNS, INSERT); // Rows (3, 6) were inserted
 TableModelEvent(source, 3, 6, ALL_COLUMNS, DELETE); // Rows (3, 6) were deleted
 
可以使用其他参数组合,但并不是所有的参数都有意义。通过创建子类,可以添加其他任何信息,例如:事件“将要”发生,还是“确实已经”发生。这使得 DELETE 事件中的行的指定更有用,但这并没有包含在 swing 包中,因为 JTable 只需要发送事件的通知。

警告:此类的序列化对象将与以后的 Swing 版本不兼容。当前的序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder

另请参见:
TableModel

字段摘要
static intALL_COLUMNS
          指定一行或一些行中的所有列。
protected  intcolumn
           
static intDELETE
          标识行或列的移除。
protected  intfirstRow
           
static intHEADER_ROW
          标识标题行。
static intINSERT
          标识新行或新列的添加。
protected  intlastRow
           
protected  inttype
           
static intUPDATE
          标识现有数据的更改。
 
从类 java.util.EventObject 继承的字段
source
 
构造方法摘要
TableModelEvent(TableModel source)
          如果表中的所有行数据都发生更改,那么侦听器应该丢弃基于这些行的所有状态,并重新查询 TableModel 来获得新的行计数和所有恰当值。
TableModelEvent(TableModel source, int row)
          此数据行已被更新。
TableModelEvent(TableModel source, int firstRow, int lastRow)
          行 [firstRow, lastRow] 中的数据已被更新。
TableModelEvent(TableModel source, int firstRow, int lastRow, int column)
          列 column 的 [firstRow, lastRow] 范围内的单元格已被更新。
TableModelEvent(TableModel source, int firstRow, int lastRow, int column, int type)
          从 (firstRow, column) 到 (lastRow, column) 的单元格已被更改。
 
方法摘要
 intgetColumn()
          返回事件的列。
 intgetFirstRow()
          返回第一个被更改的行。
 intgetLastRow()
          返回最后一个被更改的行。
 intgetType()
          返回事件类型,该类型为以下类型之一:INSERT、UPDATE 和 DELETE。
 
从类 java.util.EventObject 继承的方法
getSource, toString
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

INSERT

public static final int INSERT
标识新行或新列的添加。

另请参见:
常量字段值

UPDATE

public static final int UPDATE
标识现有数据的更改。

另请参见:
常量字段值

DELETE

public static final int DELETE
标识行或列的移除。

另请参见:
常量字段值

HEADER_ROW

public static final int HEADER_ROW
标识标题行。

另请参见:
常量字段值

ALL_COLUMNS

public static final int ALL_COLUMNS
指定一行或一些行中的所有列。

另请参见:
常量字段值

type

protected int type

firstRow

protected int firstRow