1 /* TableModelEvent.java --
2 Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing.event;
41 import java.util.EventObject;
43 import javax.swing.table.TableModel;
46 * An event that describes changes to a {@link TableModel}.
48 * @see javax.swing.event.TableModelListener
50 * @author Andrew Selkirk
52 public class TableModelEvent extends EventObject
54 private static final long serialVersionUID = -7849342674552212824L;
56 /** A column index representing all columns. */
57 public static final int ALL_COLUMNS = -1;
60 * An event type indicating that one or more rows have been deleted from the
63 public static final int DELETE = -1;
65 /** A row index representing the header row. */
66 public static final int HEADER_ROW = -1;
69 * An event type indicating that one or more rows have been inserted into the
72 public static final int INSERT = 1;
74 /** An event type indicating that data has been updated in the model. */
75 public static final int UPDATE = 0;
77 /** The column in the table model that the event relates to. */
78 protected int column = 0;
80 /** The first row in the table model that the event relates to. */
81 protected int firstRow = 0;
83 /** The last row in the table model that the event relates to. */
84 protected int lastRow = 0;
87 * The event type (one of {@link #UPDATE}, {@link #INSERT}, {@link #DELETE}).
89 protected int type = 0;
92 * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
93 * to the data in all columns and rows.
95 * @param source the source object (<code>null</code> not permitted).
97 * @throws IllegalArgumentException if <code>source</code> is
100 public TableModelEvent(TableModel source)
102 this(source, 0, Integer.MAX_VALUE, ALL_COLUMNS, UPDATE);
106 * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
107 * to the data in a single row across all columns.
109 * @param source the source object (<code>null</code> not permitted).
110 * @param row the updated row.
112 * @throws IllegalArgumentException if <code>source</code> is
115 public TableModelEvent(TableModel source, int row)
117 this(source, row, row, ALL_COLUMNS, UPDATE);
121 * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
122 * to the data in the specified rows across all columns.
124 * @param source the source object (<code>null</code> not permitted).
125 * @param firstRow the first row of update.
126 * @param lastRow the last row of update.
128 * @throws IllegalArgumentException if <code>source</code> is
131 public TableModelEvent(TableModel source, int firstRow, int lastRow)
133 this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE);
137 * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
138 * to the data in the specified rows and column. Use {@link #ALL_COLUMNS}
139 * for the <code>column</code> argument to indicate all columns.
141 * @param source the source object (<code>null</code> not permitted).
142 * @param firstRow the first row of update.
143 * @param lastRow the last row of update.
144 * @param column the affected column.
146 * @throws IllegalArgumentException if <code>source</code> is
149 public TableModelEvent(TableModel source, int firstRow, int lastRow,
152 this(source, firstRow, lastRow, column, UPDATE);
156 * Creates a new <code>TableModelEvent</code> indicating an operation of
157 * the specified <code>type</code> on the data in the specified rows and
158 * column. The event type is usually one of {@link #UPDATE}, {@link #INSERT},
159 * and {@link #DELETE}.
161 * @param source the source object (<code>null</code> not permitted).
162 * @param firstRow the first row of update.
163 * @param lastRow the last row of update.
164 * @param column the affected column.
165 * @param type the type of change.
167 * @throws IllegalArgumentException if <code>source</code> is
170 public TableModelEvent(TableModel source, int firstRow, int lastRow,
171 int column, int type)
174 this.firstRow = firstRow;
175 this.lastRow = lastRow;
176 this.column = column;
181 * Returns the affected column of this event.
183 * @return The column index.
185 public int getColumn()
191 * Returns the first affected row of this event.
193 * @return The row index.
195 public int getFirstRow()
201 * Returns the last affected row of this event.
203 * @return The row index.
205 public int getLastRow()
211 * Returns the type of change indicated by this event (usually one of
212 * {@link #UPDATE}, {@link #INSERT}, {@link #DELETE}).