jdk/test/javax/swing/JTable/7055065/bug7055065.java
author katleman
Thu, 20 Dec 2012 16:24:50 -0800
changeset 14856 92a1bcf46888
parent 12524 8745ce952a63
child 28071 3acb75b8df45
permissions -rw-r--r--
8004982: JDK8 source with GPL header errors Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12524
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     1
/*
14856
92a1bcf46888 8004982: JDK8 source with GPL header errors
katleman
parents: 12524
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
12524
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     4
 *
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     8
 *
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    13
 * accompanied this code).
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    14
 *
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    18
 *
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    21
 * questions.
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    22
 */
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    23
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    24
/*
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    25
 * Portions Copyright (c) 2012 IBM Corporation
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    26
 */
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    27
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    28
/* @test 1.1 2012/04/19
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    29
 * @bug 7055065
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    30
 * @summary NullPointerException when sorting JTable with empty cell
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    31
 * @author Jonathan Lu
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    32
 * @library ../../regtesthelpers/
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    33
 * @build Util
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    34
 * @run main bug7055065
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    35
 */
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    36
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    37
import java.awt.Dimension;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    38
import java.awt.Point;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    39
import java.awt.Rectangle;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    40
import java.awt.Robot;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    41
import java.awt.Toolkit;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    42
import java.awt.event.InputEvent;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    43
import java.awt.event.KeyEvent;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    44
import javax.swing.JFrame;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    45
import javax.swing.JPanel;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    46
import javax.swing.JScrollPane;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    47
import javax.swing.JTable;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    48
import javax.swing.SwingUtilities;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    49
import javax.swing.table.AbstractTableModel;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    50
import javax.swing.table.TableModel;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    51
import javax.swing.table.TableRowSorter;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    52
import sun.awt.SunToolkit;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    53
import java.util.concurrent.Callable;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    54
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    55
public class bug7055065 {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    56
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    57
    private static JTable table;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    58
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    59
    public static void main(String[] args) throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    60
        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    61
        Robot robot = new Robot();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    62
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    63
        SwingUtilities.invokeAndWait(new Runnable() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    64
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    65
            public void run() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    66
                createAndShowUI();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    67
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    68
        });
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    69
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    70
        toolkit.realSync();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    71
        clickCell(robot, 1, 1);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    72
        Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    73
                KeyEvent.VK_BACK_SPACE);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    74
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    75
        toolkit.realSync();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    76
        clickColumnHeader(robot, 1);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    77
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    78
        toolkit.realSync();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    79
        clickColumnHeader(robot, 1);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    80
    }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    81
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    82
    private static void clickCell(Robot robot, final int row, final int column)
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    83
        throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    84
        Point point = Util.invokeOnEDT(new Callable<Point>() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    85
            @Override
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    86
            public Point call() throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    87
                Rectangle rect = table.getCellRect(row, column, false);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    88
                Point point = new Point(rect.x + rect.width / 2, rect.y
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    89
                    + rect.height / 2);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    90
                SwingUtilities.convertPointToScreen(point, table);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    91
                return point;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    92
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    93
        });
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    94
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    95
        robot.mouseMove(point.x, point.y);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    96
        robot.mousePress(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    97
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    98
    }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    99
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   100
    private static void clickColumnHeader(Robot robot, final int column)
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   101
        throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   102
        Point point = Util.invokeOnEDT(new Callable<Point>() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   103
            @Override
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   104
            public Point call() throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   105
                Rectangle rect = table.getCellRect(0, column, false);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   106
                int headerHeight = table.getTableHeader().getHeight();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   107
                Point point = new Point(rect.x + rect.width / 2, rect.y
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   108
                    - headerHeight / 2);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   109
                SwingUtilities.convertPointToScreen(point, table);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   110
                return point;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   111
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   112
        });
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   113
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   114
        robot.mouseMove(point.x, point.y);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   115
        robot.mousePress(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   116
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   117
    }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   118
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   119
    private static void createAndShowUI() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   120
        JFrame frame = new JFrame("SimpleTableDemo");
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   121
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   122
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   123
        JPanel newContentPane = new JPanel();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   124
        newContentPane.setOpaque(true);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   125
        frame.setContentPane(newContentPane);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   126
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   127
        final String[] columnNames = { "String", "Number" };
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   128
        final Object[][] data = { { "aaaa", new Integer(1) },
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   129
            { "bbbb", new Integer(3) }, { "cccc", new Integer(2) },
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   130
            { "dddd", new Integer(4) }, { "eeee", new Integer(5) } };
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   131
        table = new JTable(data, columnNames);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   132
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   133
        table.setPreferredScrollableViewportSize(new Dimension(500, 400));
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   134
        table.setFillsViewportHeight(true);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   135
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   136
        TableModel dataModel = new AbstractTableModel() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   137
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   138
            public int getColumnCount() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   139
                return columnNames.length;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   140
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   141
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   142
            public int getRowCount() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   143
                return data.length;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   144
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   145
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   146
            public Object getValueAt(int row, int col) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   147
                return data[row][col];
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   148
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   149
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   150
            public String getColumnName(int column) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   151
                return columnNames[column];
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   152
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   153
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   154
            public Class<?> getColumnClass(int c) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   155
                return getValueAt(0, c).getClass();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   156
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   157
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   158
            public boolean isCellEditable(int row, int col) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   159
                return col != 5;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   160
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   161
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   162
            public void setValueAt(Object aValue, int row, int column) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   163
                data[row][column] = aValue;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   164
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   165
        };
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   166
        table.setModel(dataModel);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   167
        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   168
                dataModel);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   169
        table.setRowSorter(sorter);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   170
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   171
        JScrollPane scrollPane = new JScrollPane(table);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   172
        newContentPane.add(scrollPane);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   173
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   174
        frame.pack();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   175
        frame.setLocation(0, 0);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   176
        frame.setVisible(true);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   177
    }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   178
}