src/demo/share/jfc/TableExample/OldJTable.java
author dholmes
Sun, 15 Sep 2019 21:00:15 -0400
changeset 58142 24df796eef3d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231033: Problemlist ReservedStackTest 8231034: ProblemList failing ThreadMXBean tests Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
     2
 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
10292
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    32
/*
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    33
 * This source code is provided to illustrate the usage of a given feature
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    34
 * or technique and has been deliberately simplified. Additional steps
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    35
 * required for a production-quality application, such as security checks,
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    36
 * input validation and proper error handling, might not be present in
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    37
 * this sample code.
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    38
 */
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    39
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8979
diff changeset
    40
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    42
import java.util.EventObject;
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    43
import java.util.List;
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    44
import javax.swing.JTable;
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    45
import javax.swing.table.DefaultTableModel;
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    46
import javax.swing.table.TableCellEditor;
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    47
import javax.swing.table.TableCellRenderer;
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    48
import javax.swing.table.TableColumn;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *  The OldJTable is an unsupported class containing some methods that were
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *  deleted from the JTable between releases 0.6 and 0.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 */
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    55
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public class OldJTable extends JTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
   /*
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    59
    *  A new convenience method returning the index of the column in the
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    60
    *  co-ordinate space of the view.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public int getColumnIndex(Object identifier) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        return getColumnModel().getColumnIndex(identifier);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
//  Methods deleted from the JTable because they only work with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
//  DefaultTableModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public TableColumn addColumn(Object columnIdentifier, int width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        return addColumn(columnIdentifier, width, null, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    75
    public TableColumn addColumn(Object columnIdentifier, List columnData) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        return addColumn(columnIdentifier, -1, null, null, columnData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    // Override the new JTable implementation - it will not add a column to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    // DefaultTableModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public TableColumn addColumn(Object columnIdentifier, int width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                                 TableCellRenderer renderer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                 TableCellEditor editor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        return addColumn(columnIdentifier, width, renderer, editor, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public TableColumn addColumn(Object columnIdentifier, int width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                                 TableCellRenderer renderer,
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    89
                                 TableCellEditor editor, List columnData) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        checkDefaultTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        // Set up the model side first
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        DefaultTableModel m = (DefaultTableModel)getModel();
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    94
        m.addColumn(columnIdentifier, columnData.toArray());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        // The column will have been added to the end, so the index of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        // column in the model is the last element.
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    98
        TableColumn newColumn = new TableColumn(
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
    99
                m.getColumnCount()-1, width, renderer, editor);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        super.addColumn(newColumn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        return newColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    // Not possilble to make this work the same way ... change it so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    // it does not delete columns from the model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public void removeColumn(Object columnIdentifier) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        super.removeColumn(getColumn(columnIdentifier));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public void addRow(Object[] rowData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        checkDefaultTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        ((DefaultTableModel)getModel()).addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   115
    public void addRow(List rowData) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        checkDefaultTableModel();
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   117
        ((DefaultTableModel)getModel()).addRow(rowData.toArray());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public void removeRow(int rowIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        checkDefaultTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        ((DefaultTableModel)getModel()).removeRow(rowIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public void moveRow(int startIndex, int endIndex, int toIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        checkDefaultTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        ((DefaultTableModel)getModel()).moveRow(startIndex, endIndex, toIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public void insertRow(int rowIndex, Object[] rowData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        checkDefaultTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        ((DefaultTableModel)getModel()).insertRow(rowIndex, rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   135
    public void insertRow(int rowIndex, List rowData) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        checkDefaultTableModel();
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   137
        ((DefaultTableModel)getModel()).insertRow(rowIndex, rowData.toArray());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public void setNumRows(int newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        checkDefaultTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        ((DefaultTableModel)getModel()).setNumRows(newSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   145
    public void setDataVector(Object[][] newData, List columnIds) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        checkDefaultTableModel();
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   147
        ((DefaultTableModel)getModel()).setDataVector(
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   148
                newData, columnIds.toArray());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public void setDataVector(Object[][] newData, Object[] columnIds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        checkDefaultTableModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        ((DefaultTableModel)getModel()).setDataVector(newData, columnIds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    protected void checkDefaultTableModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if(!(dataModel instanceof DefaultTableModel))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            throw new InternalError("In order to use this method, the data model must be an instance of DefaultTableModel.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
//  Methods removed from JTable in the move from identifiers to ints.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public Object getValueAt(Object columnIdentifier, int rowIndex) {
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   166
        return super.getValueAt(rowIndex, getColumnIndex(columnIdentifier));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    public boolean isCellEditable(Object columnIdentifier, int rowIndex) {
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   170
        return super.isCellEditable(rowIndex, getColumnIndex(columnIdentifier));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public void setValueAt(Object aValue, Object columnIdentifier, int rowIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        super.setValueAt(aValue, rowIndex, getColumnIndex(columnIdentifier));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public boolean editColumnRow(Object identifier, int row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        return super.editCellAt(row, getColumnIndex(identifier));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public void moveColumn(Object columnIdentifier, Object targetColumnIdentifier) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        moveColumn(getColumnIndex(columnIdentifier),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                   getColumnIndex(targetColumnIdentifier));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public boolean isColumnSelected(Object identifier) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return isColumnSelected(getColumnIndex(identifier));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public TableColumn addColumn(int modelColumn, int width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        return addColumn(modelColumn, width, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public TableColumn addColumn(int modelColumn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        return addColumn(modelColumn, 75, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *  Creates a new column with <I>modelColumn</I>, <I>width</I>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *  <I>renderer</I>, and <I>editor</I> and adds it to the end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *  the JTable's array of columns. This method also retrieves the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *  name of the column using the model's <I>getColumnName(modelColumn)</I>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *  method, and sets the both the header value and the identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *  for this TableColumn accordingly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *  The <I>modelColumn</I> is the index of the column in the model which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *  will supply the data for this column in the table. This, like the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *  <I>columnIdentifier</I> in previous releases, does not change as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *  columns are moved in the view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *  For the rest of the JTable API, and all of its associated classes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *  columns are referred to in the co-ordinate system of the view, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *  index of the column in the model is kept inside the TableColumn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *  and is used only to retrieve the information from the appropraite
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *  column in the model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *  @param  modelColumn     The index of the column in the model
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *  @param  width           The new column's width.  Or -1 to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *                          the default width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *  @param  renderer        The renderer used with the new column.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *                          Or null to use the default renderer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *  @param  editor          The editor used with the new column.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *                          Or null to use the default editor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public TableColumn addColumn(int modelColumn, int width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                 TableCellRenderer renderer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                 TableCellEditor editor) {
8979
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   229
        TableColumn newColumn = new TableColumn(
30050c8aea19 7027701: /jfc/TableExample demo needs to be improved
mrkam
parents: 5506
diff changeset
   230
                modelColumn, width, renderer, editor);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        addColumn(newColumn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return newColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
//  Methods that had their arguments switched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
// These won't work with the new table package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public Object getValueAt(int columnIndex, int rowIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        return super.getValueAt(rowIndex, columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public boolean isCellEditable(int columnIndex, int rowIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return super.isCellEditable(rowIndex, columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public void setValueAt(Object aValue, int columnIndex, int rowIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        super.setValueAt(aValue, rowIndex, columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public boolean editColumnRow(int columnIndex, int rowIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return super.editCellAt(rowIndex, columnIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public boolean editColumnRow(int columnIndex, int rowIndex, EventObject e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return super.editCellAt(rowIndex, columnIndex, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
}  // End Of Class OldJTable