jdk/test/javax/swing/JInternalFrame/Test6505027.java
author brutisso
Mon, 16 Dec 2013 13:43:06 +0100
changeset 22204 eef85c68cec0
parent 20438 9954b898591b
child 40128 e635645d2a8a
permissions -rw-r--r--
8027440: DefNew does not log heap change information when a promotion failure occurs Reviewed-by: tamao, jmasa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     1
/*
20438
9954b898591b 8012466: [TEST_BUG] javax/swing/JInternalFrame/Test6505027.java doesn't release mouse button
kshefov
parents: 5506
diff changeset
     2
 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     4
 *
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     8
 *
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    13
 * accompanied this code).
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    14
 *
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3502
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3502
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3502
diff changeset
    21
 * questions.
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    22
 */
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    23
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    24
/*
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    25
 * @test
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    26
 * @bug 6505027
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    27
 * @summary Tests focus problem inside internal frame
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    29
 * @library ..
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    30
 */
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    31
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    32
import java.awt.AWTException;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    33
import java.awt.BorderLayout;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    34
import java.awt.Component;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    35
import java.awt.Container;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    36
import java.awt.KeyboardFocusManager;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    37
import java.awt.Point;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    38
import java.awt.Robot;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    39
import java.awt.event.InputEvent;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    40
import javax.swing.DefaultCellEditor;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    41
import javax.swing.JComboBox;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    42
import javax.swing.JDesktopPane;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    43
import javax.swing.JFrame;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    44
import javax.swing.JInternalFrame;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    45
import javax.swing.JScrollPane;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    46
import javax.swing.JTable;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    47
import javax.swing.JTextField;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    48
import javax.swing.SwingUtilities;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    49
import javax.swing.table.DefaultTableModel;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    50
import javax.swing.table.TableColumn;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    51
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    52
public class Test6505027 {
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    53
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    54
    private static final boolean INTERNAL = true;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    55
    private static final boolean TERMINATE = true;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    56
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    57
    private static final int WIDTH = 450;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    58
    private static final int HEIGHT = 200;
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    59
    private static final int OFFSET = 10;
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    60
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    61
    private static final String[] COLUMNS = { "Size", "Shape" }; // NON-NLS: column names
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    62
    private static final String[] ITEMS = { "a", "b", "c", "d" }; // NON-NLS: combobox content
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    63
    private static final String KEY = "terminateEditOnFocusLost"; // NON-NLS: property name
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    64
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    65
    public static void main(String[] args) throws Throwable {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    66
        SwingTest.start(Test6505027.class);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    67
    }
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    68
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    69
    private final JTable table = new JTable(new DefaultTableModel(COLUMNS, 2));
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    70
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    71
    public Test6505027(JFrame main) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    72
        Container container = main;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    73
        if (INTERNAL) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    74
            JInternalFrame frame = new JInternalFrame();
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    75
            frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    76
            frame.setVisible(true);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    77
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    78
            JDesktopPane desktop = new JDesktopPane();
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    79
            desktop.add(frame, new Integer(1));
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    80
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    81
            container.add(desktop);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    82
            container = frame;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    83
        }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    84
        if (TERMINATE) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    85
            this.table.putClientProperty(KEY, Boolean.TRUE);
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
    86
        }
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    87
        TableColumn column = this.table.getColumn(COLUMNS[1]);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    88
        column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    89
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    90
        container.add(BorderLayout.NORTH, new JTextField());
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    91
        container.add(BorderLayout.CENTER, new JScrollPane(this.table));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    92
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    93
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    94
    public void press() throws AWTException {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    95
        Point point = this.table.getCellRect(1, 1, false).getLocation();
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    96
        SwingUtilities.convertPointToScreen(point, this.table);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    97
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
    98
        Robot robot = new Robot();
20438
9954b898591b 8012466: [TEST_BUG] javax/swing/JInternalFrame/Test6505027.java doesn't release mouse button
kshefov
parents: 5506
diff changeset
    99
        robot.setAutoDelay(50);
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
   100
        robot.mouseMove(point.x + 1, point.y + 1);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
   101
        robot.mousePress(InputEvent.BUTTON1_MASK);
20438
9954b898591b 8012466: [TEST_BUG] javax/swing/JInternalFrame/Test6505027.java doesn't release mouse button
kshefov
parents: 5506
diff changeset
   102
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
   103
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
   104
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
   105
    public static void validate() {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents: 3341
diff changeset
   106
        Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
   107
        if (!component.getClass().equals(JComboBox.class)) {
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
   108
            throw new Error("unexpected focus owner: " + component);
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
   109
        }
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
   110
    }
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents:
diff changeset
   111
}