jdk/test/javax/swing/JTable/7027139/bug7027139.java
author rupashka
Tue, 13 Mar 2012 13:18:07 +0200
changeset 12173 80420757767c
permissions -rw-r--r--
7027139: getFirstIndex() does not return the first index that has changed Reviewed-by: alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12173
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     1
/*
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     4
 *
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     7
 * published by the Free Software Foundation.
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     8
 *
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    13
 * accompanied this code).
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    14
 *
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    18
 *
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    21
 * questions.
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    22
 */
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    23
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    24
/* @test
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    25
   @bug 7027139
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    26
   @summary getFirstIndex() does not return the first index that has changed
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    27
   @author Pavel Porvatov
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    28
*/
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    29
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    30
import javax.swing.*;
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    31
import javax.swing.event.ListSelectionEvent;
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    32
import javax.swing.event.ListSelectionListener;
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    33
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    34
public class bug7027139 {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    35
    public static void main(String[] args) throws Exception {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    36
        SwingUtilities.invokeAndWait(new Runnable() {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    37
            public void run() {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    38
                JTable orderTable = new JTable(new String[][]{
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    39
                        {"Item 1 1", "Item 1 2"},
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    40
                        {"Item 2 1", "Item 2 2"},
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    41
                        {"Item 3 1", "Item 3 2"},
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    42
                        {"Item 4 1", "Item 4 2"},
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    43
                },
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    44
                        new String[]{"Col 1", "Col 2"});
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    45
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    46
                ListSelectionModel selectionModel = orderTable.getSelectionModel();
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    47
                selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    48
                selectionModel.addListSelectionListener(new ListSelectionListener() {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    49
                    public void valueChanged(ListSelectionEvent e) {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    50
                        if (e.getValueIsAdjusting()) {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    51
                            return;
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    52
                        }
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    53
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    54
                        if (e.getFirstIndex() < 0) {
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    55
                            throw new RuntimeException("Test bug7027139 failed");
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    56
                        }
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    57
                    }
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    58
                });
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    59
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    60
                orderTable.selectAll();
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    61
            }
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    62
        });
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    63
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    64
        System.out.println("Test bug7027139 passed");
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    65
    }
80420757767c 7027139: getFirstIndex() does not return the first index that has changed
rupashka
parents:
diff changeset
    66
}