jdk/test/javax/swing/JTable/7055065/bug7055065.java
author yan
Fri, 21 Nov 2014 16:11:03 +0300
changeset 28071 3acb75b8df45
parent 14856 92a1bcf46888
child 40128 e635645d2a8a
permissions -rw-r--r--
8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2 8064573: [TEST_BUG] javax/swing/text/AbstractDocument/6968363/Test6968363.java is asocial pressing VK_LEFT and not releasing 8064575: [TEST_BUG] javax/swing/JEditorPane/6917744/bug6917744.java 100 times press keys and never releases 8064809: [TEST_BUG] javax/swing/JComboBox/4199622/bug4199622.java contains a lot of keyPress and not a single keyRelease Reviewed-by: alexsch, pchelko
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.event.InputEvent;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    42
import java.awt.event.KeyEvent;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    43
import javax.swing.JFrame;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    44
import javax.swing.JPanel;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    45
import javax.swing.JScrollPane;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    46
import javax.swing.JTable;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    47
import javax.swing.SwingUtilities;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    48
import javax.swing.table.AbstractTableModel;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    49
import javax.swing.table.TableModel;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    50
import javax.swing.table.TableRowSorter;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    51
import java.util.concurrent.Callable;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    52
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    53
public class bug7055065 {
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
    private static JTable table;
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
    public static void main(String[] args) throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    58
        Robot robot = new Robot();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    59
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    60
        SwingUtilities.invokeAndWait(new Runnable() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    61
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    62
            public void run() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    63
                createAndShowUI();
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
        });
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    66
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 14856
diff changeset
    67
        robot.waitForIdle();
12524
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    68
        clickCell(robot, 1, 1);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    69
        Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    70
                KeyEvent.VK_BACK_SPACE);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    71
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 14856
diff changeset
    72
        robot.waitForIdle();
12524
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    73
        clickColumnHeader(robot, 1);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    74
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 14856
diff changeset
    75
        robot.waitForIdle();
12524
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
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    79
    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
    80
        throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    81
        Point point = Util.invokeOnEDT(new Callable<Point>() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    82
            @Override
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    83
            public Point call() throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    84
                Rectangle rect = table.getCellRect(row, column, false);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    85
                Point point = new Point(rect.x + rect.width / 2, rect.y
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    86
                    + rect.height / 2);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    87
                SwingUtilities.convertPointToScreen(point, table);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    88
                return point;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    89
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    90
        });
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    91
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    92
        robot.mouseMove(point.x, point.y);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    93
        robot.mousePress(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    94
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    95
    }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    96
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    97
    private static void clickColumnHeader(Robot robot, final int column)
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    98
        throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
    99
        Point point = Util.invokeOnEDT(new Callable<Point>() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   100
            @Override
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   101
            public Point call() throws Exception {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   102
                Rectangle rect = table.getCellRect(0, column, false);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   103
                int headerHeight = table.getTableHeader().getHeight();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   104
                Point point = new Point(rect.x + rect.width / 2, rect.y
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   105
                    - headerHeight / 2);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   106
                SwingUtilities.convertPointToScreen(point, table);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   107
                return point;
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   108
            }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   109
        });
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   110
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   111
        robot.mouseMove(point.x, point.y);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   112
        robot.mousePress(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   113
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   114
    }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   115
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   116
    private static void createAndShowUI() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   117
        JFrame frame = new JFrame("SimpleTableDemo");
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   118
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   119
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   120
        JPanel newContentPane = new JPanel();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   121
        newContentPane.setOpaque(true);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   122
        frame.setContentPane(newContentPane);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   123
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   124
        final String[] columnNames = { "String", "Number" };
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   125
        final Object[][] data = { { "aaaa", new Integer(1) },
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   126
            { "bbbb", new Integer(3) }, { "cccc", new Integer(2) },
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   127
            { "dddd", new Integer(4) }, { "eeee", new Integer(5) } };
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   128
        table = new JTable(data, columnNames);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   129
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   130
        table.setPreferredScrollableViewportSize(new Dimension(500, 400));
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   131
        table.setFillsViewportHeight(true);
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
        TableModel dataModel = new AbstractTableModel() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   134
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   135
            public int getColumnCount() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   136
                return columnNames.length;
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
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   139
            public int getRowCount() {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   140
                return data.length;
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
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   143
            public Object getValueAt(int row, int col) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   144
                return data[row][col];
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
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   147
            public String getColumnName(int column) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   148
                return columnNames[column];
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
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   151
            public Class<?> getColumnClass(int c) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   152
                return getValueAt(0, c).getClass();
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
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   155
            public boolean isCellEditable(int row, int col) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   156
                return col != 5;
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
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   159
            public void setValueAt(Object aValue, int row, int column) {
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   160
                data[row][column] = aValue;
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
        };
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   163
        table.setModel(dataModel);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   164
        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   165
                dataModel);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   166
        table.setRowSorter(sorter);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   167
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   168
        JScrollPane scrollPane = new JScrollPane(table);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   169
        newContentPane.add(scrollPane);
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
        frame.pack();
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   172
        frame.setLocation(0, 0);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   173
        frame.setVisible(true);
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   174
    }
8745ce952a63 7055065: NullPointerException when sorting JTable with empty cell
luchsh
parents:
diff changeset
   175
}