|
Java example source code file (TableModelEvent.java)
The TableModelEvent.java Java example source code/* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.swing.event; import java.util.EventObject; import javax.swing.table.*; /** * TableModelEvent is used to notify listeners that a table model * has changed. The model event describes changes to a TableModel * and all references to rows and columns are in the co-ordinate * system of the model. * Depending on the parameters used in the constructors, the TableModelevent * can be used to specify the following types of changes: * * <pre> * 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 * </pre> * * It is possible to use other combinations of the parameters, not all of them * are meaningful. By subclassing, you can add other information, for example: * whether the event WILL happen or DID happen. This makes the specification * of rows in DELETE events more useful but has not been included in * the swing package as the JTable only needs post-event notification. * <p> * <strong>Warning: * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans™ * has been added to the <code>java.beans package. * Please see {@link java.beans.XMLEncoder}. * * @author Alan Chung * @author Philip Milne * @see TableModel */ public class TableModelEvent extends java.util.EventObject { /** Identifies the addition of new rows or columns. */ public static final int INSERT = 1; /** Identifies a change to existing data. */ public static final int UPDATE = 0; /** Identifies the removal of rows or columns. */ public static final int DELETE = -1; /** Identifies the header row. */ public static final int HEADER_ROW = -1; /** Specifies all columns in a row or rows. */ public static final int ALL_COLUMNS = -1; // // Instance Variables // protected int type; protected int firstRow; protected int lastRow; protected int column; // // Constructors // /** * All row data in the table has changed, listeners should discard any state * that was based on the rows and requery the <code>TableModel * to get the new row count and all the appropriate values. * The <code>JTable will repaint the entire visible region on * receiving this event, querying the model for the cell values that are visible. * The structure of the table ie, the column names, types and order * have not changed. */ public TableModelEvent(TableModel source) { // Use Integer.MAX_VALUE instead of getRowCount() in case rows were deleted. this(source, 0, Integer.MAX_VALUE, ALL_COLUMNS, UPDATE); } /** * This row of data has been updated. * To denote the arrival of a completely new table with a different structure * use <code>HEADER_ROW as the value for the Other Java examples (source code examples)Here is a short list of links related to this Java TableModelEvent.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.