jdk/src/share/classes/javax/swing/table/TableModel.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 23010 6dadb192ad81
permissions -rw-r--r--
8041917: unexcepted behavior of LineBorder while using Boolean variable true Reviewed-by: alexsch, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21982
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *  The <code>TableModel</code> interface specifies the methods the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *  <code>JTable</code> will use to interrogate a tabular data model. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *  The <code>JTable</code> can be set up to display any data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *  model which implements the
21982
fd6e5fe509df 8029264: [doclint] more doclint and tidy cleanup
yan
parents: 20455
diff changeset
    37
 *  <code>TableModel</code> interface with a couple of lines of code:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *  <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *      TableModel myData = new MyTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *      JTable table = new JTable(myData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *  </pre><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 5506
diff changeset
    43
 * For further documentation, see <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#data">Creating a Table Model</a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * in <em>The Java Tutorial</em>.
21982
fd6e5fe509df 8029264: [doclint] more doclint and tidy cleanup
yan
parents: 20455
diff changeset
    45
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @author Philip Milne
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @see JTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public interface TableModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Returns the number of rows in the model. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * <code>JTable</code> uses this method to determine how many rows it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * should display.  This method should be quick, as it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * is called frequently during rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @return the number of rows in the model
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @see #getColumnCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public int getRowCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Returns the number of columns in the model. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * <code>JTable</code> uses this method to determine how many columns it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * should create and display by default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @return the number of columns in the model
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @see #getRowCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public int getColumnCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Returns the name of the column at <code>columnIndex</code>.  This is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * to initialize the table's column header name.  Note: this name does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * not need to be unique; two columns in a table can have the same name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param   columnIndex     the index of the column
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @return  the name of the column
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public String getColumnName(int columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Returns the most specific superclass for all the cell values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * in the column.  This is used by the <code>JTable</code> to set up a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * default renderer and editor for the column.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @param columnIndex  the index of the column
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @return the common ancestor class of the object values in the model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public Class<?> getColumnClass(int columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Returns true if the cell at <code>rowIndex</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * <code>columnIndex</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * is editable.  Otherwise, <code>setValueAt</code> on the cell will not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * change the value of that cell.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param   rowIndex        the row whose value to be queried
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param   columnIndex     the column whose value to be queried
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @return  true if the cell is editable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @see #setValueAt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public boolean isCellEditable(int rowIndex, int columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Returns the value for the cell at <code>columnIndex</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <code>rowIndex</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param   rowIndex        the row whose value is to be queried
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param   columnIndex     the column whose value is to be queried
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @return  the value Object at the specified cell
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public Object getValueAt(int rowIndex, int columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Sets the value in the cell at <code>columnIndex</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * <code>rowIndex</code> to <code>aValue</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @param   aValue           the new value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param   rowIndex         the row whose value is to be changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param   columnIndex      the column whose value is to be changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @see #getValueAt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @see #isCellEditable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public void setValueAt(Object aValue, int rowIndex, int columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Adds a listener to the list that is notified each time a change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * to the data model occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param   l               the TableModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public void addTableModelListener(TableModelListener l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Removes a listener from the list that is notified each time a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * change to the data model occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @param   l               the TableModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public void removeTableModelListener(TableModelListener l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
}