< prev index next >

src/java.desktop/share/classes/javax/swing/event/TableModelEvent.java

Print this page




  41  * TableModelEvent(source, HEADER_ROW);  //  Structure change, reallocate TableColumns
  42  * TableModelEvent(source, 1);           //  Row 1 changed
  43  * TableModelEvent(source, 3, 6);        //  Rows 3 to 6 inclusive changed
  44  * TableModelEvent(source, 2, 2, 6);     //  Cell at (2, 6) changed
  45  * TableModelEvent(source, 3, 6, ALL_COLUMNS, INSERT); // Rows (3, 6) were inserted
  46  * TableModelEvent(source, 3, 6, ALL_COLUMNS, DELETE); // Rows (3, 6) were deleted
  47  * </pre>
  48  *
  49  * It is possible to use other combinations of the parameters, not all of them
  50  * are meaningful. By subclassing, you can add other information, for example:
  51  * whether the event WILL happen or DID happen. This makes the specification
  52  * of rows in DELETE events more useful but has not been included in
  53  * the swing package as the JTable only needs post-event notification.
  54  * <p>
  55  * <strong>Warning:</strong>
  56  * Serialized objects of this class will not be compatible with
  57  * future Swing releases. The current serialization support is
  58  * appropriate for short term storage or RMI between applications running
  59  * the same version of Swing.  As of 1.4, support for long term storage
  60  * of all JavaBeans&trade;
  61  * has been added to the <code>java.beans</code> package.
  62  * Please see {@link java.beans.XMLEncoder}.
  63  *
  64  * @author Alan Chung
  65  * @author Philip Milne
  66  * @see TableModel
  67  */
  68 @SuppressWarnings("serial") // Same-version serialization only
  69 public class TableModelEvent extends java.util.EventObject
  70 {
  71     /** Identifies the addition of new rows or columns. */
  72     public static final int INSERT =  1;
  73     /** Identifies a change to existing data. */
  74     public static final int UPDATE =  0;
  75     /** Identifies the removal of rows or columns. */
  76     public static final int DELETE = -1;
  77 
  78     /** Identifies the header row. */
  79     public static final int HEADER_ROW = -1;
  80 
  81     /** Specifies all columns in a row or rows. */


  91     protected int       type;
  92     /**
  93      * The first row that has changed.
  94      */
  95     protected int       firstRow;
  96     /**
  97      * The last row that has changed.
  98      */
  99     protected int       lastRow;
 100     /**
 101      * The column for the event.
 102      */
 103     protected int       column;
 104 
 105 //
 106 // Constructors
 107 //
 108 
 109     /**
 110      * All row data in the table has changed, listeners should discard any state
 111      * that was based on the rows and requery the <code>TableModel</code>
 112      * to get the new row count and all the appropriate values.
 113      * The <code>JTable</code> will repaint the entire visible region on
 114      * receiving this event, querying the model for the cell values that are visible.
 115      * The structure of the table ie, the column names, types and order
 116      * have not changed.
 117      *
 118      * @param source the {@code TableModel} affected by this event
 119      */
 120     public TableModelEvent(TableModel source) {
 121         // Use Integer.MAX_VALUE instead of getRowCount() in case rows were deleted.
 122         this(source, 0, Integer.MAX_VALUE, ALL_COLUMNS, UPDATE);
 123     }
 124 
 125     /**
 126      * This row of data has been updated.
 127      * To denote the arrival of a completely new table with a different structure
 128      * use <code>HEADER_ROW</code> as the value for the <code>row</code>.
 129      * When the <code>JTable</code> receives this event and its
 130      * <code>autoCreateColumnsFromModel</code>
 131      * flag is set it discards any TableColumns that it had and reallocates
 132      * default ones in the order they appear in the model. This is the
 133      * same as calling <code>setModel(TableModel)</code> on the <code>JTable</code>.
 134      *
 135      * @param source the {@code TableModel} affected by this event
 136      * @param row the row which has been updated
 137      */
 138     public TableModelEvent(TableModel source, int row) {
 139         this(source, row, row, ALL_COLUMNS, UPDATE);
 140     }
 141 
 142     /**
 143      * The data in rows [<I>firstRow</I>, <I>lastRow</I>] have been updated.
 144      *
 145      * @param source the {@code TableModel} affected by this event
 146      * @param firstRow the first row affected by this event
 147      * @param lastRow  the last row affected by this event
 148      */
 149     public TableModelEvent(TableModel source, int firstRow, int lastRow) {
 150         this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE);
 151     }
 152 
 153     /**




  41  * TableModelEvent(source, HEADER_ROW);  //  Structure change, reallocate TableColumns
  42  * TableModelEvent(source, 1);           //  Row 1 changed
  43  * TableModelEvent(source, 3, 6);        //  Rows 3 to 6 inclusive changed
  44  * TableModelEvent(source, 2, 2, 6);     //  Cell at (2, 6) changed
  45  * TableModelEvent(source, 3, 6, ALL_COLUMNS, INSERT); // Rows (3, 6) were inserted
  46  * TableModelEvent(source, 3, 6, ALL_COLUMNS, DELETE); // Rows (3, 6) were deleted
  47  * </pre>
  48  *
  49  * It is possible to use other combinations of the parameters, not all of them
  50  * are meaningful. By subclassing, you can add other information, for example:
  51  * whether the event WILL happen or DID happen. This makes the specification
  52  * of rows in DELETE events more useful but has not been included in
  53  * the swing package as the JTable only needs post-event notification.
  54  * <p>
  55  * <strong>Warning:</strong>
  56  * Serialized objects of this class will not be compatible with
  57  * future Swing releases. The current serialization support is
  58  * appropriate for short term storage or RMI between applications running
  59  * the same version of Swing.  As of 1.4, support for long term storage
  60  * of all JavaBeans&trade;
  61  * has been added to the {@code java.beans} package.
  62  * Please see {@link java.beans.XMLEncoder}.
  63  *
  64  * @author Alan Chung
  65  * @author Philip Milne
  66  * @see TableModel
  67  */
  68 @SuppressWarnings("serial") // Same-version serialization only
  69 public class TableModelEvent extends java.util.EventObject
  70 {
  71     /** Identifies the addition of new rows or columns. */
  72     public static final int INSERT =  1;
  73     /** Identifies a change to existing data. */
  74     public static final int UPDATE =  0;
  75     /** Identifies the removal of rows or columns. */
  76     public static final int DELETE = -1;
  77 
  78     /** Identifies the header row. */
  79     public static final int HEADER_ROW = -1;
  80 
  81     /** Specifies all columns in a row or rows. */


  91     protected int       type;
  92     /**
  93      * The first row that has changed.
  94      */
  95     protected int       firstRow;
  96     /**
  97      * The last row that has changed.
  98      */
  99     protected int       lastRow;
 100     /**
 101      * The column for the event.
 102      */
 103     protected int       column;
 104 
 105 //
 106 // Constructors
 107 //
 108 
 109     /**
 110      * All row data in the table has changed, listeners should discard any state
 111      * that was based on the rows and requery the {@code TableModel}
 112      * to get the new row count and all the appropriate values.
 113      * The {@code JTable} will repaint the entire visible region on
 114      * receiving this event, querying the model for the cell values that are visible.
 115      * The structure of the table ie, the column names, types and order
 116      * have not changed.
 117      *
 118      * @param source the {@code TableModel} affected by this event
 119      */
 120     public TableModelEvent(TableModel source) {
 121         // Use Integer.MAX_VALUE instead of getRowCount() in case rows were deleted.
 122         this(source, 0, Integer.MAX_VALUE, ALL_COLUMNS, UPDATE);
 123     }
 124 
 125     /**
 126      * This row of data has been updated.
 127      * To denote the arrival of a completely new table with a different structure
 128      * use {@code HEADER_ROW} as the value for the {@code row}.
 129      * When the {@code JTable} receives this event and its
 130      * {@code autoCreateColumnsFromModel}
 131      * flag is set it discards any TableColumns that it had and reallocates
 132      * default ones in the order they appear in the model. This is the
 133      * same as calling {@code setModel(TableModel)} on the {@code JTable}.
 134      *
 135      * @param source the {@code TableModel} affected by this event
 136      * @param row the row which has been updated
 137      */
 138     public TableModelEvent(TableModel source, int row) {
 139         this(source, row, row, ALL_COLUMNS, UPDATE);
 140     }
 141 
 142     /**
 143      * The data in rows [<I>firstRow</I>, <I>lastRow</I>] have been updated.
 144      *
 145      * @param source the {@code TableModel} affected by this event
 146      * @param firstRow the first row affected by this event
 147      * @param lastRow  the last row affected by this event
 148      */
 149     public TableModelEvent(TableModel source, int firstRow, int lastRow) {
 150         this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE);
 151     }
 152 
 153     /**


< prev index next >