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
This commit is contained in:
parent
4fda3e56f4
commit
005c56c6e3
@ -28,8 +28,6 @@
|
||||
@run main bug6711682
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
@ -47,13 +45,12 @@ public class bug6711682 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Point l = table.getLocationOnScreen();
|
||||
int h = table.getRowHeight();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
71
jdk/test/javax/swing/JButton/4368790/bug4368790.java
Normal file
71
jdk/test/javax/swing/JButton/4368790/bug4368790.java
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 4368790
|
||||
@summary JButton stays pressed when focus stolen
|
||||
@author Alexander Potochkin
|
||||
@run main bug4368790
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug4368790 {
|
||||
private static JButton b1;
|
||||
|
||||
private static void createGui() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setLayout(new FlowLayout());
|
||||
|
||||
b1 = new JButton("Button1");
|
||||
frame.add(b1);
|
||||
frame.add(new JButton("Button2"));
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
b1.requestFocus();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bug4368790.createGui();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.waitForIdle();
|
||||
if (b1.getModel().isPressed()) {
|
||||
throw new RuntimeException("The button is unexpectedly pressed");
|
||||
}
|
||||
}
|
||||
}
|
@ -39,10 +39,7 @@ import javax.swing.JColorChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class Test6541987 implements Runnable {
|
||||
private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws AWTException {
|
||||
@ -50,14 +47,14 @@ public class Test6541987 implements Runnable {
|
||||
// test escape after selection
|
||||
start();
|
||||
click(KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
// test double escape after editing
|
||||
start();
|
||||
click(KeyEvent.VK_1);
|
||||
click(KeyEvent.VK_0);
|
||||
click(KeyEvent.VK_ESCAPE);
|
||||
click(KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
// all windows should be closed
|
||||
for (Window window : Window.getWindows()) {
|
||||
if (window.isVisible()) {
|
||||
@ -76,7 +73,7 @@ public class Test6541987 implements Runnable {
|
||||
}
|
||||
|
||||
private static void click(int...keys) {
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
for (int key : keys) {
|
||||
robot.keyPress(key);
|
||||
}
|
||||
|
@ -29,8 +29,6 @@
|
||||
* @library ../regtesthelpers
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
@ -49,7 +47,6 @@ public class Test6827032 {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@ -57,7 +54,7 @@ public class Test6827032 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -39,7 +39,6 @@ import java.awt.Component;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Color;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JColorChooser;
|
||||
@ -47,7 +46,6 @@ import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class Test7194184 implements Runnable {
|
||||
private static JFrame frame;
|
||||
@ -60,10 +58,9 @@ public class Test7194184 implements Runnable {
|
||||
|
||||
private static void testKeyBoardAccess() throws Exception {
|
||||
Robot robot = new Robot();
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
SwingUtilities.invokeLater(new Test7194184());
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
@ -78,7 +75,7 @@ public class Test7194184 implements Runnable {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Tab to move the focus to MainSwatch
|
||||
Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
|
||||
@ -87,7 +84,7 @@ public class Test7194184 implements Runnable {
|
||||
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
|
||||
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
|
||||
Util.hitKeys(robot, KeyEvent.VK_SPACE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
|
@ -25,12 +25,13 @@
|
||||
@bug 4199622
|
||||
@summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation
|
||||
@author Vladislav Karnaukhov
|
||||
@library ../../../../lib/testlibrary
|
||||
@build jdk.testlibrary.OSInfo
|
||||
@run main bug4199622
|
||||
*/
|
||||
|
||||
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
|
||||
import sun.awt.OSInfo;
|
||||
import sun.awt.SunToolkit;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
@ -74,7 +75,6 @@ public class bug4199622 extends JFrame implements ActionListener {
|
||||
}
|
||||
|
||||
static Robot robot = null;
|
||||
static SunToolkit toolkit = null;
|
||||
|
||||
static void doTest() {
|
||||
if (robot == null) {
|
||||
@ -86,11 +86,7 @@ public class bug4199622 extends JFrame implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
if (toolkit == null) {
|
||||
throw new RuntimeException("Can't get the toolkit. Test failed");
|
||||
}
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
doActualTest();
|
||||
|
||||
@ -109,7 +105,7 @@ public class bug4199622 extends JFrame implements ActionListener {
|
||||
throw new RuntimeException("Test failed", e);
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
doActualTest();
|
||||
}
|
||||
|
||||
@ -144,12 +140,14 @@ public class bug4199622 extends JFrame implements ActionListener {
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException("Test failed", e);
|
||||
}
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.keyPress(KeyEvent.VK_END);
|
||||
toolkit.realSync();
|
||||
robot.keyRelease(KeyEvent.VK_END);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_HOME);
|
||||
toolkit.realSync();
|
||||
robot.keyRelease(KeyEvent.VK_HOME);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
static void doTestUpDown() {
|
||||
@ -166,16 +164,18 @@ public class bug4199622 extends JFrame implements ActionListener {
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException("Test failed", e);
|
||||
}
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i < nElems; i++) {
|
||||
robot.keyPress(KeyEvent.VK_DOWN);
|
||||
toolkit.realSync();
|
||||
robot.keyRelease(KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
for (int i = 0; i < nElems; i++) {
|
||||
robot.keyPress(KeyEvent.VK_UP);
|
||||
toolkit.realSync();
|
||||
robot.keyRelease(KeyEvent.VK_UP);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,17 +193,19 @@ public class bug4199622 extends JFrame implements ActionListener {
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException("Test failed", e);
|
||||
}
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
int listHeight = cb.getMaximumRowCount();
|
||||
for (int i = 0; i < nElems; i += listHeight) {
|
||||
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
|
||||
toolkit.realSync();
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
for (int i = 0; i < nElems; i += listHeight) {
|
||||
robot.keyPress(KeyEvent.VK_PAGE_UP);
|
||||
toolkit.realSync();
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_UP);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
}
|
||||
|
||||
|
214
jdk/test/javax/swing/JComboBox/4515752/DefaultButtonTest.java
Normal file
214
jdk/test/javax/swing/JComboBox/4515752/DefaultButtonTest.java
Normal file
@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4515752 4337071
|
||||
* @author Mark Davidson
|
||||
* @summary Tests the invocation of the default button within the JComboBox.
|
||||
*/
|
||||
public class DefaultButtonTest extends JFrame implements ActionListener {
|
||||
|
||||
private static boolean defaultButtonPressed = false;
|
||||
private static boolean editChanged = false;
|
||||
|
||||
private static String[] strData = {
|
||||
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
|
||||
};
|
||||
|
||||
private static String[] strData2 = {
|
||||
"One", "Two", "Three", "Four", "Five", "Six", "Seven"
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SwingUtilities.invokeAndWait(new Runnable(){
|
||||
public void run() {
|
||||
new DefaultButtonTest();
|
||||
}
|
||||
});
|
||||
test();
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
|
||||
public DefaultButtonTest() {
|
||||
getContentPane().add(new DefaultPanel(this));
|
||||
pack();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public static void test() {
|
||||
// Use Robot to automate the test
|
||||
Robot robot = null;
|
||||
try {
|
||||
robot = new Robot();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
robot.setAutoDelay(125);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// Test ENTER press on the non editable combo.
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
testDefaultButton(true);
|
||||
|
||||
// Test the ENTER press on the editable combo box
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
testDefaultButton(true);
|
||||
|
||||
// Change the value, should generate a change but not a Default Button press.
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_D);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_D);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
testEditChange(true);
|
||||
robot.waitForIdle();
|
||||
testDefaultButton(true);
|
||||
|
||||
// Change value, changing focus should fire an ActionEvent.
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_BACK_SPACE);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
robot.waitForIdle();
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.waitForIdle();
|
||||
testEditChange(true);
|
||||
robot.waitForIdle();
|
||||
testDefaultButton(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
String cmd = evt.getActionCommand();
|
||||
System.out.println("ActionEvent: " + cmd);
|
||||
|
||||
if (cmd.equals("OK")) {
|
||||
defaultButtonPressed = true;
|
||||
}
|
||||
|
||||
if (cmd.equals("comboBoxChanged")) {
|
||||
editChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void testDefaultButton(boolean flag) {
|
||||
if (defaultButtonPressed != flag) {
|
||||
new RuntimeException("defaultButtonPressed unexpectedly = " + defaultButtonPressed);
|
||||
}
|
||||
// reset
|
||||
defaultButtonPressed = false;
|
||||
}
|
||||
|
||||
public static void testEditChange(boolean flag) {
|
||||
if (editChanged != flag) {
|
||||
new RuntimeException("editChanged unexpectedly = " + editChanged);
|
||||
}
|
||||
// reset
|
||||
editChanged = false;
|
||||
}
|
||||
|
||||
class DefaultPanel extends JPanel {
|
||||
|
||||
public JComboBox combo;
|
||||
public JComboBox combo2;
|
||||
|
||||
private JButton okButton = new JButton("OK");
|
||||
private JButton cancelButton = new JButton("Cancel");
|
||||
|
||||
public DefaultPanel(JFrame root) {
|
||||
setLayout(new BorderLayout());
|
||||
add(createPanel(), BorderLayout.NORTH);
|
||||
add(createInfoPanel(), BorderLayout.CENTER);
|
||||
add(createButtonPanel(root), BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
private JPanel createPanel() {
|
||||
combo = new JComboBox(strData);
|
||||
combo.addActionListener(DefaultButtonTest.this);
|
||||
combo2 = new JComboBox(strData2);
|
||||
combo2.setEditable(true);
|
||||
combo2.addActionListener(DefaultButtonTest.this);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
|
||||
panel.add(combo);
|
||||
panel.add(combo2);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JScrollPane createInfoPanel() {
|
||||
StringBuffer txt = new StringBuffer("Test for 4337071:\n");
|
||||
txt.append("ENTER pressed in NON-EDITABLE combo box should be passed to the OK button.\n");
|
||||
txt.append("For an EDITABLE combo box, the combo box should fire an action event.");
|
||||
txt.append("\n\nTest for 4515752:\n");
|
||||
txt.append("ENTER on an EDITABLE combo box in which the contents has not changed\n");
|
||||
txt.append("should be passed to the default button");
|
||||
|
||||
JTextArea text = new JTextArea(txt.toString());
|
||||
text.setEditable(false);
|
||||
|
||||
return new JScrollPane(text);
|
||||
}
|
||||
|
||||
|
||||
private JPanel createButtonPanel(JFrame frame) {
|
||||
frame.getRootPane().setDefaultButton(okButton);
|
||||
|
||||
// This is just to check when the OK Button was pressed.
|
||||
okButton.addActionListener(DefaultButtonTest.this);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.add(okButton);
|
||||
panel.add(cancelButton);
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -27,8 +27,6 @@
|
||||
* @author Alexander Potochkin
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
@ -39,7 +37,6 @@ import javax.swing.plaf.basic.BasicComboPopup;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
public class bug4743225 extends JFrame {
|
||||
@ -80,21 +77,20 @@ public class bug4743225 extends JFrame {
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
new bug4743225().setVisible(true);
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// calling this method from main thread is ok
|
||||
Point point = cb.getLocationOnScreen();
|
||||
robot.mouseMove(point.x + 10, point.y + 10);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -31,8 +31,6 @@
|
||||
@run main bug6236162
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.plaf.metal.MetalComboBoxUI;
|
||||
@ -40,7 +38,6 @@ import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6236162 {
|
||||
private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
private static JFrame frame;
|
||||
private static JComboBox combo;
|
||||
private static MyComboUI comboUI;
|
||||
@ -52,7 +49,6 @@ public class bug6236162 {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
test();
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
@ -78,11 +74,11 @@ public class bug6236162 {
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
// Open popup menu
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
|
||||
// Move mouse to the first popup menu item
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
Point p = combo.getLocationOnScreen();
|
||||
Dimension size = combo.getSize();
|
||||
p.x += size.width / 2;
|
||||
@ -94,10 +90,10 @@ public class bug6236162 {
|
||||
}
|
||||
|
||||
// Select the second popup menu item
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
JList list = comboUI.getComboPopup().getList();
|
||||
if (list.getSelectedIndex() != 1) {
|
||||
throw new RuntimeException("There is an inconsistence in combo box " +
|
||||
@ -106,9 +102,6 @@ public class bug6236162 {
|
||||
}
|
||||
}
|
||||
|
||||
private static void realSync() {
|
||||
((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
|
||||
}
|
||||
|
||||
// Gives access to BasicComboBoxUI.popup field
|
||||
private static class MyComboUI extends MetalComboBoxUI {
|
||||
|
101
jdk/test/javax/swing/JComboBox/6559152/bug6559152.java
Normal file
101
jdk/test/javax/swing/JComboBox/6559152/bug6559152.java
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6559152
|
||||
@summary Checks that you can select an item in JComboBox with keyboard
|
||||
when it is a JTable cell editor.
|
||||
@author Mikhail Lapshin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug6559152
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6559152 {
|
||||
private JFrame frame;
|
||||
private JComboBox cb;
|
||||
private ExtendedRobot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final bug6559152 test = new bug6559152();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
test.setupUI();
|
||||
}
|
||||
});
|
||||
test.test();
|
||||
} finally {
|
||||
if (test.frame != null) {
|
||||
test.frame.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupUI() {
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
DefaultTableModel model = new DefaultTableModel(1, 1);
|
||||
JTable table = new JTable(model);
|
||||
|
||||
cb = new JComboBox(new String[]{"one", "two", "three"});
|
||||
cb.setEditable(true);
|
||||
table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(cb));
|
||||
frame.add(cb);
|
||||
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void test() throws Exception {
|
||||
robot = new ExtendedRobot();
|
||||
robot.waitForIdle();
|
||||
testImpl();
|
||||
robot.waitForIdle();
|
||||
checkResult();
|
||||
}
|
||||
|
||||
private void testImpl() throws Exception {
|
||||
robot.type(KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
robot.type(KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
robot.type(KeyEvent.VK_ENTER);
|
||||
}
|
||||
|
||||
private void checkResult() {
|
||||
if (cb.getSelectedItem().equals("two")) {
|
||||
System.out.println("Test passed");
|
||||
} else {
|
||||
System.out.println("Test failed");
|
||||
throw new RuntimeException("Cannot select an item " +
|
||||
"from popup with the ENTER key.");
|
||||
}
|
||||
}
|
||||
}
|
@ -30,8 +30,6 @@
|
||||
* @author Mikhail Lapshin
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
@ -79,44 +77,44 @@ public class bug6607130 {
|
||||
}
|
||||
|
||||
private void test() throws Exception {
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
test1();
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
checkResult("First test");
|
||||
test2();
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
checkResult("Second test");
|
||||
}
|
||||
|
||||
private void test1() throws Exception {
|
||||
// Select 'one'
|
||||
hitKey(KeyEvent.VK_TAB);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
hitKey(KeyEvent.VK_F2);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
hitKey(KeyEvent.VK_DOWN);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
hitKey(KeyEvent.VK_DOWN);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
hitKey(KeyEvent.VK_ENTER);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Select 'one' again
|
||||
hitKey(KeyEvent.VK_F2);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
hitKey(KeyEvent.VK_DOWN);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
hitKey(KeyEvent.VK_ENTER);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
private void test2() throws Exception {
|
||||
// Press F2 and then press ENTER
|
||||
// Editor should be shown and then closed
|
||||
hitKey(KeyEvent.VK_F2);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
hitKey(KeyEvent.VK_ENTER);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
private void checkResult(String testName) {
|
||||
@ -129,10 +127,6 @@ public class bug6607130 {
|
||||
}
|
||||
}
|
||||
|
||||
private static void realSync() {
|
||||
((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
|
||||
}
|
||||
|
||||
public void hitKey(int keycode) {
|
||||
robot.keyPress(keycode);
|
||||
robot.keyRelease(keycode);
|
||||
|
@ -29,6 +29,7 @@
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @author Alexey Ivanov
|
||||
* @run main bug8032878
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
@ -36,8 +37,6 @@ import java.awt.event.KeyEvent;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug8032878 implements Runnable {
|
||||
private static final String ONE = "one";
|
||||
private static final String TWO = "two";
|
||||
@ -99,15 +98,15 @@ public class bug8032878 implements Runnable {
|
||||
}
|
||||
|
||||
private void runTest() throws Exception {
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
// Select 'one'
|
||||
Util.hitKeys(robot, KeyEvent.VK_TAB);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
Util.hitKeys(robot, KeyEvent.VK_1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_2);
|
||||
Util.hitKeys(robot, KeyEvent.VK_3);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
private void checkResult() throws Exception {
|
||||
@ -125,9 +124,6 @@ public class bug8032878 implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private static void realSync() {
|
||||
((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -30,7 +30,6 @@ import java.awt.event.KeyEvent;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.WindowConstants;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -47,7 +46,6 @@ public class bug8057893 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
JFrame frame = new JFrame();
|
||||
@ -69,13 +67,13 @@ public class bug8057893 {
|
||||
comboBox.requestFocusInWindow();
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if(!isComboBoxEdited){
|
||||
throw new RuntimeException("ComboBoxEdited event is not fired!");
|
||||
|
@ -38,8 +38,8 @@ import java.awt.image.BufferedImage;
|
||||
public class bug6683775 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
GraphicsConfiguration gc = getGC();
|
||||
if (!AWTUtilities.isTranslucencySupported(
|
||||
AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
|
||||
if (!AWTUtilities.isTranslucencySupported(
|
||||
AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
|
||||
|| gc == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import javax.swing.JButton;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.AlphaComposite;
|
||||
@ -46,7 +45,9 @@ import java.awt.image.BufferedImage;
|
||||
* @summary Swing components fail to hide after calling hide()
|
||||
* @author Jonathan Lu
|
||||
* @library ../../regtesthelpers/
|
||||
* @library ../../../../lib/testlibrary/
|
||||
* @build Util
|
||||
* @build ExtendedRobot
|
||||
* @run main bug7154030
|
||||
*/
|
||||
|
||||
@ -61,9 +62,7 @@ public class bug7154030 {
|
||||
|
||||
BufferedImage imageHide = null;
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
Robot robot = new Robot();
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -89,7 +88,7 @@ public class bug7154030 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle(500);
|
||||
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -100,13 +99,13 @@ public class bug7154030 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle(500);
|
||||
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
if (Util.compareBufferedImages(imageInit, imageShow)) {
|
||||
throw new Exception("Failed to show opaque button");
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -116,7 +115,7 @@ public class bug7154030 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle(500);
|
||||
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
if (!Util.compareBufferedImages(imageInit, imageHide)) {
|
||||
@ -133,7 +132,7 @@ public class bug7154030 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle(500);
|
||||
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -144,7 +143,7 @@ public class bug7154030 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle(500);
|
||||
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -159,7 +158,7 @@ public class bug7154030 {
|
||||
throw new Exception("Failed to show non-opaque button");
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle(500);
|
||||
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
if (!Util.compareBufferedImages(imageInit, imageHide)) {
|
||||
|
@ -33,8 +33,6 @@ import java.awt.event.KeyEvent;
|
||||
import java.io.IOException;
|
||||
import javax.swing.*;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6917744 {
|
||||
private static JFrame frame;
|
||||
|
||||
@ -45,7 +43,6 @@ public class bug6917744 {
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
@ -70,13 +67,14 @@ public class bug6917744 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Check that we at the end of document
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -89,13 +87,14 @@ public class bug6917744 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
robot.keyPress(KeyEvent.VK_PAGE_UP);
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_UP);
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Check that we at the begin of document
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
@ -25,24 +25,23 @@
|
||||
* @test
|
||||
* @bug 4524490
|
||||
* @summary Tests if in JFileChooser, ALT+L does not bring focus to 'Files' selection list in Motif LAF
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @author Konstantin Eremin
|
||||
* @library ../../regtesthelpers
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build Util jdk.testlibrary.OSInfo
|
||||
* @run main bug4524490
|
||||
*/
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.*;
|
||||
import sun.awt.OSInfo;
|
||||
import sun.awt.SunToolkit;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
|
||||
public class bug4524490 {
|
||||
|
||||
private static JFileChooser fileChooser;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -56,7 +55,7 @@ public class bug4524490 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
|
||||
|
@ -37,7 +37,6 @@ import java.nio.file.Files;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.UIManager;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -56,7 +55,6 @@ public class bug7199708 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -70,7 +68,7 @@ public class bug7199708 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
@ -108,14 +106,14 @@ public class bug7199708 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
int d = 25;
|
||||
for (int i = 0; i < width / d; i++) {
|
||||
robot.mouseMove(locationX + i * d, locationY + 5);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
|
@ -28,7 +28,6 @@ import javax.swing.JFileChooser;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UIManager.LookAndFeelInfo;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -54,7 +53,6 @@ public class bug8002077 {
|
||||
}
|
||||
|
||||
private static void runTest() throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -63,17 +61,17 @@ public class bug8002077 {
|
||||
fileChooserState = new JFileChooser().showSaveDialog(null);
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_N);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (fileChooserState != JFileChooser.APPROVE_OPTION) {
|
||||
throw new RuntimeException("Save button is not pressed!");
|
||||
|
@ -32,7 +32,6 @@ import java.awt.event.KeyEvent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -50,7 +49,6 @@ public class bug8021253 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -60,7 +58,7 @@ public class bug8021253 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@ -68,11 +66,11 @@ public class bug8021253 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!defaultKeyPressed) {
|
||||
throw new RuntimeException("Default button is not pressed");
|
||||
|
@ -33,7 +33,6 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Random;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4962534 extends Applet {
|
||||
|
||||
@ -45,7 +44,6 @@ public class bug4962534 extends Applet {
|
||||
Component titleComponent;
|
||||
JLayeredPane lPane;
|
||||
volatile boolean titleFound = false;
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
public static Object LOCK = new Object();
|
||||
|
||||
@Override
|
||||
@ -91,13 +89,13 @@ public class bug4962534 extends Applet {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(70);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
|
||||
framePosition.y + titleComponent.getHeight() / 2);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
gcBounds =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getConfigurations()[0].getBounds();
|
||||
@ -105,7 +103,7 @@ public class bug4962534 extends Applet {
|
||||
robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
|
||||
framePosition.y + titleComponent.getHeight() / 2);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
int multier = gcBounds.height / 2 - 10; //we will not go out the borders
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@ -113,7 +111,7 @@ public class bug4962534 extends Applet {
|
||||
}
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
} catch (AWTException e) {
|
||||
throw new RuntimeException("Test Failed. AWTException thrown." + e.getMessage());
|
||||
|
@ -22,21 +22,21 @@
|
||||
*/
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import sun.awt.OSInfo;
|
||||
import sun.awt.SunToolkit;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 7124513
|
||||
* @summary We should support NSTexturedBackgroundWindowMask style on OSX.
|
||||
* @author Sergey Bylokhov
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build ExtendedRobot jdk.testlibrary.OSInfo
|
||||
* @run main NSTexturedJFrame
|
||||
*/
|
||||
public final class NSTexturedJFrame {
|
||||
|
||||
@ -46,12 +46,15 @@ public final class NSTexturedJFrame {
|
||||
private static Rectangle bounds;
|
||||
private static volatile int step;
|
||||
private static JFrame frame;
|
||||
private static ExtendedRobot robot;
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
|
||||
System.out.println("This test is for OSX, considered passed.");
|
||||
return;
|
||||
}
|
||||
robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(50);
|
||||
// Default window appearance
|
||||
showFrame();
|
||||
step++;
|
||||
@ -84,12 +87,10 @@ public final class NSTexturedJFrame {
|
||||
}
|
||||
|
||||
private static void showFrame() throws Exception {
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
createUI();
|
||||
images[step] = robot.createScreenCapture(bounds);
|
||||
SwingUtilities.invokeAndWait(frame::dispose);
|
||||
sleep();
|
||||
robot.waitForIdle(1000);
|
||||
}
|
||||
|
||||
private static void createUI() throws Exception {
|
||||
@ -107,15 +108,11 @@ public final class NSTexturedJFrame {
|
||||
}
|
||||
frame.setVisible(true);
|
||||
});
|
||||
sleep();
|
||||
robot.waitForIdle(1000);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
bounds = frame.getBounds();
|
||||
});
|
||||
sleep();
|
||||
robot.waitForIdle(1000);
|
||||
}
|
||||
|
||||
private static void sleep() throws InterruptedException {
|
||||
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
@ -32,21 +32,19 @@
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import sun.awt.*;
|
||||
|
||||
public class bug5066752
|
||||
{
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
|
||||
Robot r = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
tk.realSync();
|
||||
r.waitForIdle();
|
||||
|
||||
r.delay(600);
|
||||
|
||||
|
@ -32,7 +32,6 @@ import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -79,7 +78,6 @@ public class bug8020708 {
|
||||
}
|
||||
|
||||
static void testInternalFrameMnemonic() throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -103,25 +101,26 @@ public class bug8020708 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point clickPoint = Util.getCenterPoint(internalFrame);
|
||||
robot.mouseMove(clickPoint.x, clickPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_C);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
robot.delay(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (internalFrame.isVisible()) {
|
||||
throw new RuntimeException("Close mnemonic does not work");
|
||||
throw new RuntimeException("Close mnemonic does not work in "+UIManager.getLookAndFeel());
|
||||
}
|
||||
frame.dispose();
|
||||
}
|
||||
|
@ -27,8 +27,6 @@
|
||||
@author mcherkas
|
||||
@run main InternalFrameIsNotCollectedTest
|
||||
*/
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyVetoException;
|
||||
@ -41,12 +39,6 @@ public class InternalFrameIsNotCollectedTest {
|
||||
private static Robot robot;
|
||||
private static CustomInternalFrame iFrame;
|
||||
|
||||
public static void sync() {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
initRobot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -60,7 +52,7 @@ public class InternalFrameIsNotCollectedTest {
|
||||
}
|
||||
}
|
||||
});
|
||||
sync();
|
||||
robot.waitForIdle();
|
||||
invokeGC();
|
||||
System.runFinalization();
|
||||
Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later
|
||||
@ -134,4 +126,4 @@ public class InternalFrameIsNotCollectedTest {
|
||||
waiter.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6462008 {
|
||||
|
||||
@ -41,11 +40,9 @@ public class bug6462008 {
|
||||
private static boolean isAquaLAF;
|
||||
private static int controlKey;
|
||||
private static JList list;
|
||||
private static SunToolkit toolkit;
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
@ -60,15 +57,15 @@ public class bug6462008 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
setAnchorLead(-1);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
testListSelection();
|
||||
|
||||
setAnchorLead(100);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
testListSelection();
|
||||
}
|
||||
@ -79,10 +76,10 @@ public class bug6462008 {
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Control + Space
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
@ -90,10 +87,10 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Shift + Space
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
@ -101,10 +98,10 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Control + Shift + Space
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
@ -114,10 +111,10 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelection();
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
// Control + A Multiple Selection
|
||||
@ -127,11 +124,11 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
resetList();
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Control + A Single Selection
|
||||
robot.keyPress(controlKey);
|
||||
@ -139,12 +136,12 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(0, 0, 0);
|
||||
resetList();
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
setSelectionInterval(5, 5);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
// Control + A Selection interval (5, 5)
|
||||
@ -153,10 +150,10 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelection(5);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Page Down
|
||||
// Not applicable for the Aqua L&F
|
||||
@ -164,10 +161,10 @@ public class bug6462008 {
|
||||
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelection(9, 9, 9);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
// Shift + Page Down
|
||||
@ -184,28 +181,28 @@ public class bug6462008 {
|
||||
|
||||
scrollDownExtendSelection();
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelection(0, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Down
|
||||
robot.keyPress(KeyEvent.VK_DOWN);
|
||||
robot.keyRelease(KeyEvent.VK_DOWN);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(0, 0, 0);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// L
|
||||
robot.keyPress(KeyEvent.VK_L);
|
||||
robot.keyRelease(KeyEvent.VK_L);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(0, 0, 0);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Click item 4
|
||||
Point p = clickItem4();
|
||||
@ -214,10 +211,10 @@ public class bug6462008 {
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(4, 4, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
// Control + Click item 4
|
||||
@ -229,10 +226,10 @@ public class bug6462008 {
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(4, 4, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Shift + Click item 4
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
@ -243,10 +240,10 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(0, 4, 0, 1, 2, 3, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
// Control + Shift + Click item 4
|
||||
@ -259,10 +256,10 @@ public class bug6462008 {
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
robot.keyRelease(controlKey);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectionAL(0, 4);
|
||||
resetList();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
private static DefaultListModel getModel() {
|
||||
|
74
jdk/test/javax/swing/JList/6510999/bug6510999.java
Normal file
74
jdk/test/javax/swing/JList/6510999/bug6510999.java
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6510999
|
||||
@summary Selection in a JList with both scrollbars visible jumps on arrowkey-down
|
||||
@author Alexander Potochkin
|
||||
@run main bug6510999
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6510999 {
|
||||
private static JScrollPane s;
|
||||
|
||||
private static void createGui() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
DefaultListModel dlm = new DefaultListModel();
|
||||
for (int i = 0; i < 100; i++)
|
||||
dlm
|
||||
.addElement(i + " listItemlistItemlistItemlistItemItem");
|
||||
JList l = new JList();
|
||||
l.setModel(dlm);
|
||||
s = new JScrollPane(l);
|
||||
l.setSelectedIndex(50);
|
||||
l.ensureIndexIsVisible(50);
|
||||
|
||||
frame.add(s);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bug6510999.createGui();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point viewPosition = s.getViewport().getViewPosition();
|
||||
robot.keyPress(KeyEvent.VK_DOWN);
|
||||
robot.keyRelease(KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
if (!s.getViewport().getViewPosition().equals(viewPosition)) {
|
||||
throw new RuntimeException("JScrollPane was unexpectedly scrolled");
|
||||
}
|
||||
}
|
||||
}
|
79
jdk/test/javax/swing/JMenu/4417601/bug4417601.java
Normal file
79
jdk/test/javax/swing/JMenu/4417601/bug4417601.java
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 4417601
|
||||
@summary JMenus with no items paint a tiny menu.
|
||||
@author Alexander Potochkin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug4417601
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class bug4417601 {
|
||||
static JMenu menu;
|
||||
static volatile boolean flag;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
menu = new JMenu("Menu");
|
||||
JMenuBar bar = new JMenuBar();
|
||||
bar.add(menu);
|
||||
frame.setJMenuBar(bar);
|
||||
|
||||
frame.getLayeredPane().addContainerListener(new ContainerAdapter() {
|
||||
public void componentAdded(ContainerEvent e) {
|
||||
flag = true;
|
||||
}
|
||||
});
|
||||
|
||||
frame.pack();
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point p = menu.getLocationOnScreen();
|
||||
Dimension size = menu.getSize();
|
||||
p.x += size.width / 2;
|
||||
p.y += size.height / 2;
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
if (flag) {
|
||||
throw new RuntimeException("Empty popup was shown");
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,6 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -107,7 +106,6 @@ public class bug4515762 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
|
||||
@ -123,17 +121,17 @@ public class bug4515762 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_D);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Press the S key many times (should not cause an action peformed)
|
||||
int TIMES = 5;
|
||||
for (int i = 0; i < TIMES; i++) {
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
}
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Unique menu items.
|
||||
actionExpected = true;
|
||||
@ -141,31 +139,31 @@ public class bug4515762 {
|
||||
|
||||
robot.keyPress(KeyEvent.VK_S);
|
||||
robot.keyRelease(KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
robot.keyPress(KeyEvent.VK_M);
|
||||
robot.keyRelease(KeyEvent.VK_M);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_T);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_W);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_U);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4692443 {
|
||||
|
||||
@ -56,29 +55,23 @@ public class bug4692443 {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
robo.waitForIdle();
|
||||
|
||||
try {
|
||||
robo = new Robot();
|
||||
} catch (AWTException e) {
|
||||
throw new RuntimeException("Robot could not be created");
|
||||
}
|
||||
int altKey = java.awt.event.KeyEvent.VK_ALT;
|
||||
robo.setAutoDelay(100);
|
||||
Util.hitMnemonics(robo, KeyEvent.VK_F); // Enter File menu
|
||||
robo.keyPress(KeyEvent.VK_S); // Enter submenu
|
||||
robo.keyRelease(KeyEvent.VK_S);
|
||||
robo.keyPress(KeyEvent.VK_O); // Launch "One" action
|
||||
robo.keyRelease(KeyEvent.VK_O);
|
||||
robo.keyPress(KeyEvent.VK_M); // Launch "One" action
|
||||
robo.keyRelease(KeyEvent.VK_M);
|
||||
int altKey = java.awt.event.KeyEvent.VK_ALT;
|
||||
robo.setAutoDelay(100);
|
||||
Util.hitMnemonics(robo, KeyEvent.VK_F); // Enter File menu
|
||||
robo.keyPress(KeyEvent.VK_S); // Enter submenu
|
||||
robo.keyRelease(KeyEvent.VK_S);
|
||||
robo.keyPress(KeyEvent.VK_O); // Launch "One" action
|
||||
robo.keyRelease(KeyEvent.VK_O);
|
||||
robo.keyPress(KeyEvent.VK_M); // Launch "One" action
|
||||
robo.keyRelease(KeyEvent.VK_M);
|
||||
|
||||
toolkit.realSync();
|
||||
robo.waitForIdle();
|
||||
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Test failed.");
|
||||
}
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Test failed.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
84
jdk/test/javax/swing/JMenu/6359669/bug6359669.java
Normal file
84
jdk/test/javax/swing/JMenu/6359669/bug6359669.java
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6359669
|
||||
@summary REGRESSION: Submenu does not work if populated in PopupMenuListener.popupMenuWillBecomeVisible
|
||||
@author Alexander Potochkin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug6359669
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
public class bug6359669 {
|
||||
static JMenu menu;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
JFrame f = new JFrame();
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menu = new JMenu("Test");
|
||||
menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
}
|
||||
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||
}
|
||||
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
menu.add(new JMenuItem("An item"));
|
||||
}
|
||||
});
|
||||
|
||||
menuBar.add(menu);
|
||||
f.setJMenuBar(menuBar);
|
||||
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setSize(200, 200);
|
||||
f.setVisible(true);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point p = menu.getLocationOnScreen();
|
||||
Dimension size = menu.getSize();
|
||||
p.x += size.width / 2;
|
||||
p.y += size.height / 2;
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
if (menu.getPopupMenu().getComponentCount() == 0) {
|
||||
throw new RuntimeException("Where is a menuItem ?");
|
||||
}
|
||||
}
|
||||
}
|
84
jdk/test/javax/swing/JMenu/6470128/bug6470128.java
Normal file
84
jdk/test/javax/swing/JMenu/6470128/bug6470128.java
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6470128
|
||||
@summary Escape Key causes JMenu Selection to Disappear
|
||||
@author Alexander Potochkin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build jdk.testlibrary.OSInfo
|
||||
@run main bug6470128
|
||||
*/
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
|
||||
public class bug6470128 {
|
||||
static JFrame frame;
|
||||
static JMenu subMenu;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JMenuBar bar = new JMenuBar();
|
||||
JMenu menu = new JMenu("Menu");
|
||||
menu.setMnemonic('m');
|
||||
subMenu = new JMenu("SubMenu");
|
||||
JMenuItem item = new JMenuItem("Item");
|
||||
|
||||
frame.setJMenuBar(bar);
|
||||
bar.add(menu);
|
||||
menu.add(subMenu);
|
||||
subMenu.add(item);
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.waitForIdle();
|
||||
if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
robot.keyPress(KeyEvent.VK_ALT);
|
||||
robot.keyPress(KeyEvent.VK_M);
|
||||
robot.keyRelease(KeyEvent.VK_M);
|
||||
robot.keyRelease(KeyEvent.VK_ALT);
|
||||
if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
robot.waitForIdle();
|
||||
if (!subMenu.isSelected()) {
|
||||
throw new RuntimeException("Submenu is unexpectedly unselected");
|
||||
}
|
||||
}
|
||||
}
|
131
jdk/test/javax/swing/JMenu/6538132/bug6538132.java
Normal file
131
jdk/test/javax/swing/JMenu/6538132/bug6538132.java
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6538132
|
||||
@summary Regression: Pressing Escape key don't close the menu items from jdk7.0 b07 onwards
|
||||
@author Alexander Potochkin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug6538132
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6538132 {
|
||||
private static JMenu menu1;
|
||||
private static JMenu menu2;
|
||||
private static volatile boolean isWinLaf;
|
||||
|
||||
private static void createGui() {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
isWinLaf = true;
|
||||
} catch (Exception e) {
|
||||
// If we can't set WinLaf it means we are not under Windows
|
||||
// make the test pass
|
||||
isWinLaf = false;
|
||||
return;
|
||||
}
|
||||
JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menu1 = createMenu();
|
||||
menuBar.add(menu1);
|
||||
menu2 = createMenu();
|
||||
menuBar.add(menu2);
|
||||
frame.setJMenuBar(menuBar);
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
static JMenu createMenu() {
|
||||
JMenu menu = new JMenu("Menu");
|
||||
menu.add(new JMenuItem("MenuItem"));
|
||||
menu.add(new JMenuItem("MenuItem"));
|
||||
menu.add(new JMenuItem("MenuItem"));
|
||||
return menu;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bug6538132.createGui();
|
||||
}
|
||||
});
|
||||
if(isWinLaf) {
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.waitForIdle();
|
||||
Point p1 = menu1.getLocationOnScreen();
|
||||
final int x1 = p1.x + menu1.getWidth() / 2;
|
||||
final int y1 = p1.y + menu1.getHeight() / 2;
|
||||
robot.glide(0, 0, x1, y1);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
assertPopupOpen();
|
||||
Point p2 = menu2.getLocationOnScreen();
|
||||
final int x2 = p2.x + menu2.getWidth() / 2;
|
||||
final int y2 = p2.y + menu2.getHeight() / 2;
|
||||
robot.glide(x1, y1, x2, y2);
|
||||
assertPopupOpen();
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
assertPopupNotOpen();
|
||||
robot.glide(x2, y2, x1, y1);
|
||||
assertPopupNotOpen();
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
assertPopupOpen();
|
||||
}
|
||||
}
|
||||
|
||||
static void assertPopupOpen() {
|
||||
if (getLastPopup() == null) {
|
||||
throw new RuntimeException("PopupMenu is not open");
|
||||
}
|
||||
}
|
||||
|
||||
static void assertPopupNotOpen() {
|
||||
if (getLastPopup() != null) {
|
||||
throw new RuntimeException("PopupMenu is unexpectedly open");
|
||||
}
|
||||
}
|
||||
|
||||
// copied from BasicPopupMenuUI
|
||||
static JPopupMenu getLastPopup() {
|
||||
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
|
||||
MenuElement[] p = msm.getSelectedPath();
|
||||
JPopupMenu popup = null;
|
||||
|
||||
for (int i = p.length - 1; popup == null && i >= 0; i--) {
|
||||
if (p[i] instanceof JPopupMenu)
|
||||
popup = (JPopupMenu) p[i];
|
||||
}
|
||||
return popup;
|
||||
}
|
||||
}
|
@ -48,16 +48,15 @@ public class bug4750590 {
|
||||
}
|
||||
});
|
||||
|
||||
sun.awt.SunToolkit toolkit = (sun.awt.SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
|
||||
Robot robo = new Robot();
|
||||
robo.setAutoDelay(500);
|
||||
robo.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robo, KeyEvent.VK_F);
|
||||
robo.keyPress(KeyEvent.VK_M);
|
||||
robo.keyRelease(KeyEvent.VK_M);
|
||||
|
||||
toolkit.realSync();
|
||||
robo.waitForIdle();
|
||||
|
||||
if (passed) {
|
||||
System.out.println("Test passed!");
|
||||
|
@ -32,7 +32,6 @@ import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4171437 {
|
||||
static volatile boolean closeActivated = false;
|
||||
@ -45,16 +44,14 @@ public class bug4171437 {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_F);
|
||||
Util.hitKeys(robot, KeyEvent.VK_C);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!closeActivated || customActivated) {
|
||||
|
@ -36,7 +36,6 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.concurrent.Callable;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4654927 {
|
||||
|
||||
@ -51,7 +50,6 @@ public class bug4654927 {
|
||||
}
|
||||
|
||||
UIManager.setLookAndFeel(systemLAF);
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
@ -61,20 +59,20 @@ public class bug4654927 {
|
||||
createAndShowUI();
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// test mouse press
|
||||
Point point = Util.getCenterPoint(menu);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
point = Util.getCenterPoint(menuItem);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!isMenuItemShowing()) {
|
||||
throw new RuntimeException("Popup is unexpectedly closed");
|
||||
@ -107,12 +105,12 @@ public class bug4654927 {
|
||||
// close menu
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
Util.glide(robot, x0, y0, x1, y1);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!isMenuItemShowing()) {
|
||||
throw new RuntimeException("Popup is unexpectedly closed");
|
||||
|
@ -25,15 +25,12 @@
|
||||
* @test
|
||||
* @bug 6209975
|
||||
* @summary regression: JMenuItem icons overimposed on JMenuItem labels under Metal LAF
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @author Alexander Zuev
|
||||
* @run main bug6209975
|
||||
*/
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6209975 {
|
||||
|
||||
@ -45,7 +42,6 @@ public class bug6209975 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
|
||||
@ -58,19 +54,19 @@ public class bug6209975 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point clickPoint = getButtonClickPoint();
|
||||
robot.mouseMove(clickPoint.x, clickPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickPoint = getMenuClickPoint();
|
||||
robot.mouseMove(clickPoint.x, clickPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (RO1.itsValue <= RO2.itsValue) {
|
||||
throw new RuntimeException("Offset if the second icon is invalid.");
|
||||
|
105
jdk/test/javax/swing/JMenuItem/6249972/bug6249972.java
Normal file
105
jdk/test/javax/swing/JMenuItem/6249972/bug6249972.java
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6249972
|
||||
@summary Tests that JMenuItem(String,int) handles lower-case mnemonics properly.
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@author Mikhail Lapshin
|
||||
@run main bug6249972
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6249972 implements ActionListener {
|
||||
|
||||
|
||||
private JFrame frame;
|
||||
private JMenu menu;
|
||||
private volatile boolean testPassed = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
bug6249972 bugTest = new bug6249972();
|
||||
bugTest.test();
|
||||
}
|
||||
|
||||
public bug6249972() throws Exception {
|
||||
SwingUtilities.invokeAndWait(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame("bug6249972");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JMenuBar bar = new JMenuBar();
|
||||
frame.setJMenuBar(bar);
|
||||
|
||||
menu = new JMenu("Problem");
|
||||
bar.add(menu);
|
||||
|
||||
JMenuItem item = new JMenuItem("JMenuItem(String,'z')", 'z');
|
||||
item.addActionListener(bug6249972.this);
|
||||
menu.add(item);
|
||||
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private void test() throws Exception {
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.waitForIdle();
|
||||
java.awt.Point p = menu.getLocationOnScreen();
|
||||
java.awt.Dimension size = menu.getSize();
|
||||
p.x += size.width / 2;
|
||||
p.y += size.height / 2;
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.click();
|
||||
robot.delay(100);
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.type(KeyEvent.VK_Z);
|
||||
|
||||
robot.waitForIdle();
|
||||
frame.dispose(); // Try to stop the event dispatch thread
|
||||
|
||||
if (!testPassed) {
|
||||
throw new RuntimeException("JMenuItem(String,int) does not handle " +
|
||||
"lower-case mnemonics properly.");
|
||||
}
|
||||
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// We are in the actionPerformed() method -
|
||||
// JMenuItem(String,int) handles lower-case mnemonics properly
|
||||
testPassed = true;
|
||||
}
|
||||
}
|
@ -26,10 +26,12 @@
|
||||
* @bug 7160951
|
||||
* @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
|
||||
* @author vera.akulova@oracle.com
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build jdk.testlibrary.OSInfo
|
||||
* @run main ActionListenerCalledTwiceTest
|
||||
*/
|
||||
|
||||
import sun.awt.*;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
@ -47,7 +49,7 @@ public class ActionListenerCalledTwiceTest {
|
||||
|
||||
static volatile int listenerCallCounter = 0;
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
|
||||
if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
|
||||
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
|
||||
return;
|
||||
}
|
||||
@ -59,7 +61,6 @@ public class ActionListenerCalledTwiceTest {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
@ -78,7 +79,7 @@ public class ActionListenerCalledTwiceTest {
|
||||
robot.keyRelease(modKeyCode);
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (listenerCallCounter != 1) {
|
||||
throw new Exception("Test failed: ActionListener for " + menuItems[i] +
|
||||
|
114
jdk/test/javax/swing/JOptionPane/6428694/bug6428694.java
Normal file
114
jdk/test/javax/swing/JOptionPane/6428694/bug6428694.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
@test
|
||||
@bug 6428694
|
||||
@summary Checks that double click closes JOptionPane's input dialog.
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@author Mikhail Lapshin
|
||||
@run main bug6428694
|
||||
*/
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.JOptionPane;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
public class bug6428694 {
|
||||
private static JFrame frame;
|
||||
private static boolean mainIsWaitingForDialogClosing;
|
||||
private static ExtendedRobot robot;
|
||||
private static volatile boolean testPassed;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new ExtendedRobot();
|
||||
try {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
bug6428694.setupUI();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
test();
|
||||
} finally {
|
||||
stopEDT();
|
||||
}
|
||||
|
||||
if (testPassed) {
|
||||
System.out.println("Test passed");
|
||||
} else {
|
||||
throw new RuntimeException("JOptionPane doesn't close input dialog " +
|
||||
"by double click!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupUI() {
|
||||
frame = new JFrame("bug6428694 test");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
|
||||
Object[] selectedItems = new Object[40];
|
||||
for (int i = 0; i < 39; i++) {
|
||||
selectedItems[i] = ("item: " + i);
|
||||
}
|
||||
JOptionPane.showInputDialog(frame,
|
||||
"Double click on selected item then click cancel",
|
||||
"Test Option Dialog", JOptionPane.WARNING_MESSAGE, null,
|
||||
selectedItems, selectedItems[0]);
|
||||
|
||||
// We are here if double click has closed the dialog
|
||||
// or when the EDT is stopping
|
||||
testPassed = mainIsWaitingForDialogClosing;
|
||||
}
|
||||
|
||||
private static void test() {
|
||||
|
||||
mainIsWaitingForDialogClosing = true;
|
||||
|
||||
// Perform double click on an item
|
||||
int frameLeftX = frame.getLocationOnScreen().x;
|
||||
int frameUpperY = frame.getLocationOnScreen().y;
|
||||
robot.mouseMove(frameLeftX + 150, frameUpperY + 120);
|
||||
robot.waitForIdle();
|
||||
robot.delay(100);
|
||||
robot.setAutoDelay(50);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
// Wait for the input dialog closing
|
||||
robot.waitForIdle();
|
||||
robot.delay(2000);
|
||||
|
||||
mainIsWaitingForDialogClosing = false;
|
||||
}
|
||||
|
||||
private static void stopEDT() {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -27,8 +27,6 @@
|
||||
@author Pavel Porvatov
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
@ -55,16 +53,14 @@ public class bug7138665 {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
Robot robot = new Robot();
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.setAutoDelay(100);
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4458079 extends JFrame implements PopupMenuListener {
|
||||
public JMenu menu;
|
||||
@ -47,21 +46,20 @@ public class bug4458079 extends JFrame implements PopupMenuListener {
|
||||
new bug4458079().createAndShowGUI();
|
||||
}
|
||||
});
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_M);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!itemASelected) {
|
||||
|
8
jdk/test/javax/swing/JPopupMenu/4634626/bug4634626.html
Normal file
8
jdk/test/javax/swing/JPopupMenu/4634626/bug4634626.html
Normal file
@ -0,0 +1,8 @@
|
||||
<Html>
|
||||
<Body>
|
||||
<APPLET code="bug4634626.class" WIDTH = 50 HEIGHT = 50>
|
||||
</APPLET>
|
||||
|
||||
</Body>
|
||||
</Html>
|
||||
|
205
jdk/test/javax/swing/JPopupMenu/4634626/bug4634626.java
Normal file
205
jdk/test/javax/swing/JPopupMenu/4634626/bug4634626.java
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 4634626
|
||||
@summary Implement context popup menus for components
|
||||
@author Alexander Zuev
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run applet bug4634626.html
|
||||
*/
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class bug4634626 extends JApplet {
|
||||
|
||||
public boolean passed = true;
|
||||
public boolean done = false;
|
||||
|
||||
public JFrame mainFrame = new JFrame("Bug4634626");
|
||||
public JRootPane rootPane = mainFrame.getRootPane();
|
||||
public JPanel contentPane = new JPanel();
|
||||
public JButton nopButton = new JButton("No popup button");
|
||||
public JTextArea someText = new JTextArea("Some text here", 20, 10);
|
||||
public JButton popButton = new JButton("Button with the popup");
|
||||
|
||||
public JPopupMenu btnPopup = new JPopupMenu();
|
||||
public JPopupMenu commonPopup = new JPopupMenu();
|
||||
static public Error toBeThrown = null;
|
||||
static int popTrig = MouseEvent.BUTTON3_MASK;
|
||||
static boolean popt = false;
|
||||
|
||||
public static class MouseWatcher extends MouseAdapter {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if(e.isPopupTrigger()) popt = true;
|
||||
if(e.getComponent() != null &&
|
||||
e.getComponent() instanceof JComponent &&
|
||||
e.isPopupTrigger() &&
|
||||
((JComponent)e.getComponent()).getComponentPopupMenu() != null) {
|
||||
toBeThrown =
|
||||
new Error("The event got thru the component with popup: "
|
||||
+ e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if(e.isPopupTrigger()) popt = true;
|
||||
if(e.getComponent() != null &&
|
||||
e.getComponent() instanceof JComponent &&
|
||||
e.isPopupTrigger() &&
|
||||
((JComponent)e.getComponent()).getComponentPopupMenu() != null) {
|
||||
toBeThrown =
|
||||
new Error("The event got thru the component with popup: "
|
||||
+ e);
|
||||
}
|
||||
if(toBeThrown != null) {
|
||||
throw(toBeThrown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MouseWatcher mouser = new MouseWatcher();
|
||||
|
||||
public void init() {
|
||||
|
||||
try {
|
||||
popButton.setComponentPopupMenu(null);
|
||||
popButton.setComponentPopupMenu(null);
|
||||
popButton.setComponentPopupMenu(btnPopup);
|
||||
popButton.setComponentPopupMenu(null);
|
||||
} catch(Exception ex) {
|
||||
System.err.println("Unexpected exception was thrown by " +
|
||||
"setComponentPopupMenu() method: " + ex);
|
||||
}
|
||||
btnPopup.add("Button 1");
|
||||
btnPopup.add("Button 2");
|
||||
btnPopup.add("Button 3");
|
||||
popButton.setComponentPopupMenu(btnPopup);
|
||||
popButton.addMouseListener(mouser);
|
||||
commonPopup.add("One");
|
||||
commonPopup.add("Two");
|
||||
commonPopup.add("Three");
|
||||
|
||||
contentPane.setLayout(new BorderLayout());
|
||||
contentPane.setComponentPopupMenu(commonPopup);
|
||||
contentPane.addMouseListener(mouser);
|
||||
contentPane.add(nopButton, BorderLayout.NORTH);
|
||||
nopButton.addMouseListener(mouser);
|
||||
contentPane.add(popButton, BorderLayout.SOUTH);
|
||||
someText.addMouseListener(mouser);
|
||||
contentPane.add(someText, BorderLayout.CENTER);
|
||||
mainFrame.setContentPane(contentPane);
|
||||
|
||||
mainFrame.pack();
|
||||
mainFrame.setLocation(50, 50);
|
||||
|
||||
mainFrame.addWindowListener(new TestStateListener());
|
||||
mainFrame.setVisible(true);
|
||||
|
||||
while(!done) Thread.yield();
|
||||
|
||||
if(!passed) {
|
||||
throw new RuntimeException("Test failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TestStateListener extends WindowAdapter {
|
||||
public void windowOpened(WindowEvent ev) {
|
||||
try {
|
||||
ev.getWindow().toFront();
|
||||
ev.getWindow().requestFocus();
|
||||
new Thread(new RobotThread()).start();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Thread Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RobotThread implements Runnable {
|
||||
public void run() {
|
||||
ExtendedRobot robo;
|
||||
try {
|
||||
robo = new ExtendedRobot();
|
||||
}catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new RuntimeException("Cannot create Robot");
|
||||
}
|
||||
robo.setAutoDelay(100);
|
||||
robo.waitForIdle();
|
||||
|
||||
// Determine working popup trigger event
|
||||
clickMouseOn(robo, nopButton, popTrig);
|
||||
robo.waitForIdle();
|
||||
robo.delay(500);
|
||||
if(!popt) popTrig = MouseEvent.BUTTON2_MASK;
|
||||
|
||||
// Inheritance is OFF by default. Popup should not appear.
|
||||
clickMouseOn(robo, someText, popTrig);
|
||||
|
||||
// Set inheritance ON watch for popup.
|
||||
someText.setInheritsPopupMenu(true);
|
||||
clickMouseOn(robo, someText, popTrig);
|
||||
robo.waitForIdle();
|
||||
robo.delay(500);
|
||||
if(!commonPopup.isVisible()) {
|
||||
toBeThrown = new Error("Popup should be visible");
|
||||
passed = false;
|
||||
}
|
||||
// Dispose popup.
|
||||
robo.type(KeyEvent.VK_ESCAPE);
|
||||
robo.waitForIdle();
|
||||
someText.setInheritsPopupMenu(false);
|
||||
|
||||
// Button with popup assigned. Wathch for popup.
|
||||
clickMouseOn(robo, popButton, popTrig);
|
||||
robo.waitForIdle();
|
||||
robo.delay(500);
|
||||
if(!btnPopup.isVisible()) {
|
||||
toBeThrown = new Error("Popup should be visible");
|
||||
passed = false;
|
||||
}
|
||||
// Dispose popup.
|
||||
robo.type(KeyEvent.VK_ESCAPE);
|
||||
// Test finished.
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void destroy() {
|
||||
if(!passed) {
|
||||
throw(toBeThrown);
|
||||
}
|
||||
}
|
||||
private void clickMouseOn(ExtendedRobot robot, Component c, int button) {
|
||||
java.awt.Point p = c.getLocationOnScreen();
|
||||
java.awt.Dimension size = c.getSize();
|
||||
p.x += size.width / 2;
|
||||
p.y += size.height / 2;
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.delay(100);
|
||||
robot.click(button);
|
||||
}
|
||||
}
|
@ -35,7 +35,6 @@ import javax.swing.event.PopupMenuListener;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4966112 {
|
||||
|
||||
@ -50,19 +49,18 @@ public class bug4966112 {
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
createAndShowButton();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
setClickPoint(testButton);
|
||||
clickMouse(InputEvent.BUTTON1_MASK);
|
||||
clickMouse(InputEvent.BUTTON2_MASK);
|
||||
clickMouse(InputEvent.BUTTON3_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
closeFrame();
|
||||
|
||||
if (popupButton == NO_MOUSE_BUTTON) {
|
||||
@ -74,10 +72,10 @@ public class bug4966112 {
|
||||
|
||||
// Test Split Pane
|
||||
createAndShowSplitPane();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouse(jsp);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
closeFrame();
|
||||
|
||||
if (!shown) {
|
||||
@ -86,10 +84,10 @@ public class bug4966112 {
|
||||
|
||||
// Test Spinner
|
||||
createAndShowSpinner();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouse(spin);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
closeFrame();
|
||||
|
||||
if (!shown) {
|
||||
@ -98,16 +96,16 @@ public class bug4966112 {
|
||||
|
||||
// Test File Chooser
|
||||
createAndShowFileChooser();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouse(filec);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
closeFrame();
|
||||
|
||||
if (!shown) {
|
||||
|
114
jdk/test/javax/swing/JPopupMenu/6217905/bug6217905.java
Normal file
114
jdk/test/javax/swing/JPopupMenu/6217905/bug6217905.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
@test
|
||||
@bug 6217905
|
||||
@summary JPopupMenu keyboard navigation stops working
|
||||
@author Alexander Potochkin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug6217905
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6217905 {
|
||||
private static JPanel popupPanel;
|
||||
private static JMenuItem firstItem;
|
||||
private static JMenuItem lastItem;
|
||||
|
||||
private static void createGui() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JPopupMenu popup = new JPopupMenu("Menu");
|
||||
firstItem = new JMenuItem("MenuItem");
|
||||
popup.add(firstItem);
|
||||
popup.add(new JMenuItem("MenuItem"));
|
||||
lastItem = new JMenuItem("MenuItem");
|
||||
popup.add(lastItem);
|
||||
|
||||
popupPanel = new JPanel();
|
||||
popupPanel.setComponentPopupMenu(popup);
|
||||
frame.add(popupPanel);
|
||||
frame.setSize(100, 100);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
} catch (Exception e) {
|
||||
// This test is for WinLaf only
|
||||
System.out.println("This test is for Windows LaF only.");
|
||||
return;
|
||||
}
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
bug6217905.createGui();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point loc = popupPanel.getLocationOnScreen();
|
||||
int x = loc.x + popupPanel.getWidth()/2;
|
||||
int y = loc.y + popupPanel.getHeight()/2;
|
||||
robot.glide(0, 0, x, y);
|
||||
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||
robot.waitForIdle();
|
||||
if (getSelectedPathLength() != 1) {
|
||||
throw new RuntimeException("Only popup must be selected");
|
||||
}
|
||||
robot.glide(x, y, 0, 0);
|
||||
robot.type(KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
if (getSelectedPathLength() != 2 || !firstItem.isArmed()) {
|
||||
throw new RuntimeException("First item must be selected");
|
||||
}
|
||||
robot.type(KeyEvent.VK_ESCAPE);
|
||||
robot.waitForIdle();
|
||||
if (getSelectedPathLength() != 0) {
|
||||
throw new RuntimeException("There must be no selected items");
|
||||
}
|
||||
robot.glide(0, 0, x, y);
|
||||
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||
robot.waitForIdle();
|
||||
robot.glide(x, y, 0, 0);
|
||||
robot.type(KeyEvent.VK_UP);
|
||||
robot.waitForIdle();
|
||||
if (getSelectedPathLength() != 2 || !lastItem.isArmed()) {
|
||||
throw new RuntimeException("Last item must be selected");
|
||||
}
|
||||
}
|
||||
|
||||
private static int getSelectedPathLength() {
|
||||
return MenuSelectionManager.defaultManager().getSelectedPath().length;
|
||||
}
|
||||
}
|
121
jdk/test/javax/swing/JPopupMenu/6415145/bug6415145.java
Normal file
121
jdk/test/javax/swing/JPopupMenu/6415145/bug6415145.java
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
@test
|
||||
@bug 6415145
|
||||
@summary REGRESSION: Selected item is not being updated while dragging above popup menu
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@author Mikhail Lapshin
|
||||
@run main bug6415145
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Component;
|
||||
|
||||
public class bug6415145 {
|
||||
private JFrame frame;
|
||||
private JButton button;
|
||||
private JPopupMenu popupMenu;
|
||||
private JMenuItem item1;
|
||||
private JMenuItem item2;
|
||||
private static ExtendedRobot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new ExtendedRobot();
|
||||
final bug6415145 bugTest = new bug6415145();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bugTest.init();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
bugTest.test();
|
||||
} finally {
|
||||
bugTest.stopEDT();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopEDT() {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
popupMenu = new JPopupMenu("test menu");
|
||||
item1 = new JMenuItem("item 1");
|
||||
item2 = new JMenuItem("item 2");
|
||||
popupMenu.add(item1);
|
||||
popupMenu.add(item2);
|
||||
|
||||
button = new JButton("test button");
|
||||
button.addMouseListener(new MouseListener());
|
||||
|
||||
frame = new JFrame("test frame");
|
||||
frame.add(popupMenu);
|
||||
frame.add(button);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private class MouseListener extends MouseAdapter {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
popupMenu.show(button, e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
|
||||
private void test() throws AWTException {
|
||||
try {
|
||||
moveMouseTo(robot, button);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
moveMouseTo(robot, item1);
|
||||
robot.waitForIdle();
|
||||
|
||||
moveMouseTo(robot, item2);
|
||||
robot.waitForIdle();
|
||||
if ( (item1.isArmed()) || (!item2.isArmed()) ) {
|
||||
throw new RuntimeException("Selected item is not being updated" +
|
||||
" while dragging above popup menu.");
|
||||
}
|
||||
} finally {
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
}
|
||||
private void moveMouseTo(ExtendedRobot robot, Component c) {
|
||||
java.awt.Point p = c.getLocationOnScreen();
|
||||
java.awt.Dimension size = c.getSize();
|
||||
p.x += size.width / 2;
|
||||
p.y += size.height / 2;
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.delay(100);
|
||||
}
|
||||
}
|
91
jdk/test/javax/swing/JPopupMenu/6515446/bug6515446.java
Normal file
91
jdk/test/javax/swing/JPopupMenu/6515446/bug6515446.java
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
@test
|
||||
@bug 6515446
|
||||
@summary JMenuItems in JPopupMenus not receiving ActionEvents - incompat with 1.5
|
||||
@author Alexander Potochkin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug6515446
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class bug6515446 {
|
||||
private static JPanel panel;
|
||||
private static volatile boolean flag;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
final JPopupMenu popup = new JPopupMenu("Menu");
|
||||
JMenuItem item = new JMenuItem("MenuItem");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
flag = true;
|
||||
}
|
||||
});
|
||||
popup.add(item);
|
||||
|
||||
panel = new JPanel();
|
||||
panel.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
popup.show(panel, e.getX(), e.getY());
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
popup.setVisible(false);
|
||||
}
|
||||
});
|
||||
frame.add(panel);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.waitForIdle();
|
||||
|
||||
Point l = panel.getLocationOnScreen();
|
||||
|
||||
int x = l.x + panel.getWidth() / 2;
|
||||
int y = l.y + panel.getHeight() / 2;
|
||||
robot.mouseMove(x, y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.glide(x, y, x + 10, y + 10);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!flag) {
|
||||
throw new RuntimeException("ActionEvent wasn't fired");
|
||||
}
|
||||
}
|
||||
}
|
105
jdk/test/javax/swing/JPopupMenu/6544309/bug6544309.java
Normal file
105
jdk/test/javax/swing/JPopupMenu/6544309/bug6544309.java
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6544309
|
||||
@summary Checks that 'Select Input Method' popup menu allows to select
|
||||
items with keyboard.
|
||||
@author Mikhail Lapshin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug6544309
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class bug6544309 {
|
||||
private JDialog dialog;
|
||||
private boolean passed;
|
||||
private static ExtendedRobot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new ExtendedRobot();
|
||||
final bug6544309 test = new bug6544309();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
test.setupUI();
|
||||
}
|
||||
});
|
||||
test.test();
|
||||
System.out.println("Test passed");
|
||||
} finally {
|
||||
if (test.dialog != null) {
|
||||
test.dialog.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupUI() {
|
||||
dialog = new JDialog();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setSize(200, 100);
|
||||
dialog.setLocationRelativeTo(null);
|
||||
dialog.setVisible(true);
|
||||
|
||||
JPopupMenu popup = new JPopupMenu();
|
||||
popup.add(new JMenuItem("one"));
|
||||
JMenuItem two = new JMenuItem("two");
|
||||
two.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
passed = true;
|
||||
}
|
||||
});
|
||||
popup.add(two);
|
||||
popup.add(new JMenuItem("three"));
|
||||
popup.show(dialog, 50, 50);
|
||||
}
|
||||
|
||||
private void test() throws Exception {
|
||||
testImpl();
|
||||
checkResult();
|
||||
}
|
||||
|
||||
|
||||
private void testImpl() throws Exception {
|
||||
robot.waitForIdle();
|
||||
System.out.println("Pressing DOWN ARROW");
|
||||
robot.type(KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
System.out.println("Pressing DOWN ARROW");
|
||||
robot.type(KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
System.out.println("Pressing SPACE");
|
||||
robot.type(KeyEvent.VK_SPACE);
|
||||
}
|
||||
|
||||
private void checkResult() {
|
||||
robot.waitForIdle();
|
||||
if (!passed) {
|
||||
throw new RuntimeException("If a JDialog is invoker for JPopupMenu, " +
|
||||
"the menu cannot be handled by keyboard.");
|
||||
}
|
||||
}
|
||||
}
|
148
jdk/test/javax/swing/JPopupMenu/6580930/bug6580930.java
Normal file
148
jdk/test/javax/swing/JPopupMenu/6580930/bug6580930.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
@test
|
||||
@bug 6580930 7184956
|
||||
@summary Swing Popups should overlap taskbar
|
||||
@author Alexander Potochkin
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@run main bug6580930
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6580930 {
|
||||
private static ExtendedRobot robot;
|
||||
private static JFrame frame;
|
||||
private static JPopupMenu popup;
|
||||
private static Toolkit toolkit;
|
||||
private static volatile boolean skipTest = false;
|
||||
|
||||
private static void createGui() {
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setUndecorated(true);
|
||||
|
||||
popup = new JPopupMenu("Menu");
|
||||
for (int i = 0; i < 7; i++) {
|
||||
popup.add(new JMenuItem("MenuItem"));
|
||||
}
|
||||
JPanel panel = new JPanel();
|
||||
panel.setComponentPopupMenu(popup);
|
||||
frame.add(panel);
|
||||
|
||||
frame.setSize(200, 200);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
JPopupMenu.setDefaultLightWeightPopupEnabled(true);
|
||||
bug6580930.createGui();
|
||||
}
|
||||
});
|
||||
|
||||
toolkit = Toolkit.getDefaultToolkit();
|
||||
robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Insets insets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
|
||||
if (insets.bottom == 0) {
|
||||
System.out.println("This test is only for configurations with taskbar on the bottom");
|
||||
|
||||
skipTest = true;
|
||||
}
|
||||
|
||||
Dimension screenSize = toolkit.getScreenSize();
|
||||
frame.setLocation(screenSize.width/2, screenSize.height - frame.getHeight() - insets.bottom + 10);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
if(skipTest) {
|
||||
return;
|
||||
}
|
||||
Point loc = frame.getLocationOnScreen();
|
||||
|
||||
robot.mouseMove(loc.x, loc.y);
|
||||
showPopup();
|
||||
robot.waitForIdle();
|
||||
if (isHeavyWeightMenuVisible()) {
|
||||
throw new RuntimeException("HeavyWeightPopup is unexpectedly visible");
|
||||
}
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
|
||||
int x = loc.x;
|
||||
int y = loc.y + (frame.getHeight() - popup.getPreferredSize().height) + 1;
|
||||
robot.mouseMove(x, y);
|
||||
|
||||
showPopup();
|
||||
|
||||
if (!popup.getLocationOnScreen().equals(new Point(x, y))) {
|
||||
throw new RuntimeException("Popup is unexpectedly shifted");
|
||||
}
|
||||
|
||||
if (!isHeavyWeightMenuVisible()) {
|
||||
throw new RuntimeException("HeavyWeightPopup is unexpectedly hidden");
|
||||
}
|
||||
}
|
||||
|
||||
private static void showPopup() {
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
if (!popup.isShowing()) {
|
||||
robot.mousePress(InputEvent.BUTTON2_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON2_MASK);
|
||||
robot.waitForIdle();
|
||||
if (!popup.isShowing()) {
|
||||
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isHeavyWeightMenuVisible() {
|
||||
Window[] windows = Window.getWindows();
|
||||
for (Window window : windows) {
|
||||
if (window.getClass().getSimpleName().equals("HeavyWeightWindow")
|
||||
&& window.isVisible()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -32,8 +32,6 @@
|
||||
* @run main bug6800513
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
@ -47,10 +45,10 @@ public class bug6800513 {
|
||||
private static JPopupMenu popupMenu;
|
||||
private static JMenu menu;
|
||||
private static JFrame frame;
|
||||
private static Robot robot;
|
||||
|
||||
public static void testFrame(final boolean defaultLightWeightPopupEnabled,
|
||||
String expectedPopupClass) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@ -59,11 +57,11 @@ public class bug6800513 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickOnMenu();
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Field getPopup = JPopupMenu.class.getDeclaredField("popup");
|
||||
getPopup.setAccessible(true);
|
||||
@ -87,7 +85,7 @@ public class bug6800513 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +97,6 @@ public class bug6800513 {
|
||||
}
|
||||
});
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
robot.mouseMove(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
|
||||
@ -140,6 +137,7 @@ public class bug6800513 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
testFrame(false, "javax.swing.PopupFactory$HeavyWeightPopup");
|
||||
|
||||
testFrame(true, "javax.swing.PopupFactory$LightWeightPopup");
|
||||
|
@ -33,7 +33,6 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6827786 {
|
||||
|
||||
@ -41,7 +40,6 @@ public class bug6827786 {
|
||||
private static Component focusable;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -52,7 +50,7 @@ public class bug6827786 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -61,7 +59,7 @@ public class bug6827786 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkfocus();
|
||||
|
||||
// select menu
|
||||
@ -72,17 +70,17 @@ public class bug6827786 {
|
||||
}
|
||||
// select submenu
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
// verify submenu is selected
|
||||
verify(1);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
// verify last item is selected
|
||||
verify(2);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
// selection should wrap to first item
|
||||
verify(0);
|
||||
|
||||
|
@ -29,8 +29,6 @@
|
||||
* @run main bug6987844
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
@ -40,7 +38,6 @@ public class bug6987844 {
|
||||
static JMenu menu2;
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(200);
|
||||
|
||||
@ -64,7 +61,7 @@ public class bug6987844 {
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Point point1 = menu1.getLocationOnScreen();
|
||||
Point point2 = menu2.getLocationOnScreen();
|
||||
|
||||
@ -79,7 +76,7 @@ public class bug6987844 {
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.mouseMove(point1.x + 1, point1.y + 1);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -26,16 +26,17 @@
|
||||
@bug 7154841
|
||||
@summary JPopupMenu is overlapped by a Dock on Mac OS X
|
||||
@author Petr Pchelko
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot jdk.testlibrary.OSInfo
|
||||
@run main bug7154841
|
||||
*/
|
||||
|
||||
import sun.awt.OSInfo;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
|
||||
public class bug7154841 {
|
||||
|
||||
@ -71,20 +72,20 @@ public class bug7154841 {
|
||||
}
|
||||
|
||||
try {
|
||||
Robot r = new Robot();
|
||||
ExtendedRobot r = new ExtendedRobot();
|
||||
r.setAutoDelay(100);
|
||||
r.setAutoWaitForIdle(true);
|
||||
r.mouseMove(0, 0);
|
||||
|
||||
SwingUtilities.invokeAndWait(bug7154841::initAndShowUI);
|
||||
|
||||
sleep();
|
||||
r.waitForIdle(200);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
popupMenu.show(frame, frame.getX() + frame.getWidth() / 2, frame.getY() + frame.getHeight() / 2);
|
||||
});
|
||||
|
||||
sleep();
|
||||
r.waitForIdle(200);
|
||||
|
||||
int y = (int)screenBounds.get().getY() + (int)screenBounds.get().getHeight() - 10;
|
||||
int center = (int)(screenBounds.get().getX() + screenBounds.get().getWidth() / 2);
|
||||
@ -112,10 +113,4 @@ public class bug7154841 {
|
||||
.getBounds();
|
||||
}
|
||||
|
||||
private static void sleep() {
|
||||
((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException ignored) { }
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,9 @@ import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug8033699 {
|
||||
private static Robot robot;
|
||||
private static SunToolkit toolkit;
|
||||
|
||||
private static JButton btnStart;
|
||||
private static ButtonGroup btnGrp;
|
||||
@ -61,7 +59,6 @@ public class bug8033699 {
|
||||
Thread.sleep(100);
|
||||
|
||||
robot.setAutoDelay(100);
|
||||
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
// tab key test grouped radio button
|
||||
runTest1();
|
||||
@ -242,7 +239,7 @@ public class bug8033699 {
|
||||
private static void hitKey(Robot robot, int keycode) {
|
||||
robot.keyPress(keycode);
|
||||
robot.keyRelease(keycode);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
private static void hitKey(Robot robot, int mode, int keycode) {
|
||||
@ -250,6 +247,6 @@ public class bug8033699 {
|
||||
robot.keyPress(keycode);
|
||||
robot.keyRelease(mode);
|
||||
robot.keyRelease(keycode);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import java.awt.AWTException;
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
@ -34,7 +33,6 @@ import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.plaf.metal.DefaultMetalTheme;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -62,7 +60,7 @@ public class bug8041561 {
|
||||
}
|
||||
});
|
||||
|
||||
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
|
||||
new Robot().waitForIdle();
|
||||
Thread.sleep(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
@ -24,7 +24,6 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -101,7 +100,6 @@ public class bug4670486 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
|
||||
@ -120,7 +118,7 @@ public class bug4670486 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Change the default button to
|
||||
// force a call to BasicRootPaneUI.updateDefaultButtonBindings()
|
||||
@ -131,14 +129,14 @@ public class bug4670486 {
|
||||
// effect.
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4708809 {
|
||||
|
||||
@ -42,7 +41,6 @@ public class bug4708809 {
|
||||
private static JScrollBar sbar;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(350);
|
||||
|
||||
@ -53,7 +51,7 @@ public class bug4708809 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -63,13 +61,13 @@ public class bug4708809 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = getClickPoint(0.5, 0.5);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -88,12 +86,12 @@ public class bug4708809 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
point = getClickPoint(0.5, 0.2);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!do_test || !passed) {
|
||||
throw new Exception("The scrollbar moved with incorrect direction");
|
||||
@ -131,4 +129,4 @@ public class bug4708809 {
|
||||
fr.setSize(200, 200);
|
||||
fr.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,6 @@
|
||||
@run main bug6542335
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||
import java.awt.*;
|
||||
@ -43,8 +41,6 @@ public class bug6542335 {
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
final Rectangle[] thumbBounds = new Rectangle[1];
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -72,7 +68,7 @@ public class bug6542335 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@ -86,7 +82,7 @@ public class bug6542335 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -28,12 +28,9 @@
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
@ -54,12 +51,11 @@ public class Test7163696 implements Runnable {
|
||||
|
||||
private void test() throws Exception {
|
||||
Robot robot = new Robot();
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
|
||||
UIManager.setLookAndFeel(info.getClassName());
|
||||
|
||||
SwingUtilities.invokeAndWait(this);
|
||||
toolkit.realSync(); // after creation
|
||||
robot.waitForIdle(); // after creation
|
||||
Thread.sleep(1000);
|
||||
|
||||
Point point = this.bar.getLocation();
|
||||
@ -70,7 +66,7 @@ public class Test7163696 implements Runnable {
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
toolkit.realSync(); // before validation
|
||||
robot.waitForIdle(); // before validation
|
||||
Thread.sleep(1000);
|
||||
SwingUtilities.invokeAndWait(this);
|
||||
|
||||
|
@ -22,8 +22,9 @@
|
||||
*/
|
||||
/* @test
|
||||
@bug 4202954
|
||||
@library ../../../../lib/testlibrary
|
||||
@library ../../regtesthelpers
|
||||
@build Util
|
||||
@build Util jdk.testlibrary.OSInfo
|
||||
@author Michael C. Albers
|
||||
@run main bug4202954
|
||||
*/
|
||||
@ -31,11 +32,10 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import javax.swing.*;
|
||||
import sun.awt.*;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
|
||||
public class bug4202954 {
|
||||
static JScrollPane buttonScrollPane;
|
||||
private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
static Robot robot;
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
|
||||
@ -138,13 +138,17 @@ public class bug4202954 {
|
||||
}
|
||||
};
|
||||
Integer oldHValue = Util.invokeOnEDT(horizontalValue);
|
||||
robot.waitForIdle();
|
||||
Integer oldVValue = Util.invokeOnEDT(verticalValue);
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouseOnComponent(scrollButton, buttons);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
int newHValue = Util.invokeOnEDT(horizontalValue);
|
||||
robot.waitForIdle();
|
||||
int newVValue = Util.invokeOnEDT(verticalValue);
|
||||
robot.waitForIdle();
|
||||
|
||||
return (oldHValue != newHValue || oldVValue != newVValue) == expectScroll;
|
||||
}
|
||||
|
@ -29,8 +29,6 @@
|
||||
* @author Mikhail Lapshin
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import javax.swing.*;
|
||||
@ -42,13 +40,16 @@ public class bug6348946 {
|
||||
private static JFrame frame;
|
||||
|
||||
private static JPanel panel;
|
||||
private static Robot robot;
|
||||
|
||||
private static volatile boolean passed = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
String lf = "javax.swing.plaf.metal.MetalLookAndFeel";
|
||||
UIManager.setLookAndFeel(lf);
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -56,9 +57,9 @@ public class bug6348946 {
|
||||
setupUI();
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
clickOnSlider();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkResult();
|
||||
} finally {
|
||||
stopEDT();
|
||||
@ -79,9 +80,6 @@ public class bug6348946 {
|
||||
}
|
||||
|
||||
private static void clickOnSlider() throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
Rectangle rect = getPanelRectangle();
|
||||
|
||||
double clickX = rect.getX() + rect.getWidth() / 4;
|
||||
|
82
jdk/test/javax/swing/JSlider/6401380/bug6401380.java
Normal file
82
jdk/test/javax/swing/JSlider/6401380/bug6401380.java
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 6401380
|
||||
@summary JSlider - mouse click ont the left side of the knob is ignored.
|
||||
@library ../../../../lib/testlibrary
|
||||
@build ExtendedRobot
|
||||
@author Alexander Potochkin
|
||||
@run main bug6401380
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicSliderUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
public class bug6401380 extends JFrame {
|
||||
private static JSlider slider;
|
||||
|
||||
public bug6401380() {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
slider = new JSlider();
|
||||
slider.setMajorTickSpacing(0);
|
||||
slider.setMaximum(50);
|
||||
slider.setMinorTickSpacing(10);
|
||||
slider.setPaintLabels(true);
|
||||
slider.setPaintTicks(true);
|
||||
slider.setSnapToTicks(true);
|
||||
|
||||
// MetalSliderUI overrides scrollDueToClickInTrack() method
|
||||
// so this test doens't work for Metal
|
||||
slider.setUI(new BasicSliderUI(slider));
|
||||
|
||||
add(slider);
|
||||
setSize(200, 200);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
new bug6401380().setVisible(true);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
|
||||
Point l = slider.getLocationOnScreen();
|
||||
robot.glide(0, 0, l.x + slider.getWidth() / 2, l.y + slider.getHeight() / 2);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
if (slider.getValue() == slider.getMaximum()) {
|
||||
throw new RuntimeException("Slider value unchanged");
|
||||
}
|
||||
}
|
||||
}
|
@ -28,8 +28,6 @@
|
||||
* @run main bug6848475
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.SliderUI;
|
||||
import javax.swing.plaf.basic.BasicSliderUI;
|
||||
@ -47,7 +45,6 @@ public class bug6848475 {
|
||||
private static int thumbRectX;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
@ -70,7 +67,7 @@ public class bug6848475 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@ -80,7 +77,7 @@ public class bug6848475 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@ -95,7 +92,7 @@ public class bug6848475 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -30,21 +30,18 @@
|
||||
*/
|
||||
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4973721 implements ChangeListener, FocusListener {
|
||||
static volatile boolean bStateChanged = false;
|
||||
static volatile boolean bFocusGained = false;
|
||||
static JSpinner spinner;
|
||||
static final Object listener = new bug4973721();
|
||||
private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
public void focusLost(FocusEvent e) {}
|
||||
|
||||
@ -100,7 +97,7 @@ public class bug4973721 implements ChangeListener, FocusListener {
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_UP);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!bStateChanged) {
|
||||
@ -110,7 +107,7 @@ public class bug4973721 implements ChangeListener, FocusListener {
|
||||
bStateChanged = false;
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!bStateChanged) {
|
||||
|
@ -43,10 +43,10 @@ public class bug5012888 extends JFrame {
|
||||
pane.add(spinner2, BorderLayout.SOUTH);
|
||||
}
|
||||
public void doTest() throws Exception {
|
||||
((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
Point p = spinner2.getLocationOnScreen();
|
||||
Rectangle rect = spinner2.getBounds();
|
||||
Robot robot = new Robot();
|
||||
robot.mouseMove(p.x+rect.width-5, p.y+5);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
Thread.sleep(1000);
|
||||
|
@ -28,8 +28,6 @@
|
||||
* @author Andrey Pikalev
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
@ -91,9 +89,8 @@ public class bug4885629 {
|
||||
}
|
||||
});
|
||||
|
||||
((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
|
||||
|
||||
final Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
@ -25,7 +25,6 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -42,7 +41,6 @@ public class bug4361477 {
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -54,7 +52,7 @@ public class bug4361477 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
|
@ -26,8 +26,9 @@
|
||||
* @bug 4624207
|
||||
* @summary JTabbedPane mnemonics don't work from outside the tabbed pane
|
||||
* @author Oleg Mokhovikov
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @build Util jdk.testlibrary.OSInfo
|
||||
* @run main bug4624207
|
||||
*/
|
||||
import javax.swing.*;
|
||||
@ -38,8 +39,7 @@ import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import sun.awt.OSInfo;
|
||||
import sun.awt.SunToolkit;
|
||||
import jdk.testlibrary.OSInfo;
|
||||
|
||||
public class bug4624207 implements ChangeListener, FocusListener {
|
||||
|
||||
@ -65,7 +65,6 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -76,7 +75,7 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -85,7 +84,7 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!focusGained) {
|
||||
throw new RuntimeException("Couldn't gain focus for text field");
|
||||
@ -99,7 +98,7 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
|
||||
@ -107,7 +106,7 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!stateChanged || tab.getSelectedIndex() != 1) {
|
||||
throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
/*
|
||||
* @test
|
||||
* @bug 6495408
|
||||
@ -37,7 +36,6 @@ public class bug6495408 {
|
||||
static JTabbedPane tabbedPane;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -56,7 +54,7 @@ public class bug6495408 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
final Rectangle d = new Rectangle();
|
||||
final Point p = new Point();
|
||||
|
@ -23,7 +23,6 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -40,7 +39,6 @@ public class bug7161568 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.put("TabbedPane.selectionFollowsFocus", Boolean.FALSE);
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -52,7 +50,7 @@ public class bug7161568 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -62,12 +60,12 @@ public class bug7161568 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,10 @@ import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4220171 {
|
||||
|
||||
@ -47,7 +45,6 @@ public class bug4220171 {
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -58,26 +55,26 @@ public class bug4220171 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouse(robot, 0, 0);
|
||||
Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkCell(0, 0);
|
||||
|
||||
clickMouse(robot, 0, 1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkCell(0, 1);
|
||||
|
||||
clickMouse(robot, 1, 0);
|
||||
Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkCell(1, 0);
|
||||
|
||||
clickMouse(robot, 1, 1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkCell(1, 1);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6263446 {
|
||||
|
||||
@ -43,7 +42,6 @@ public class bug6263446 {
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -55,63 +53,63 @@ public class bug6263446 {
|
||||
});
|
||||
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = getClickPoint();
|
||||
robot.mouseMove(point.x, point.y);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
click(1);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
assertEditing(false);
|
||||
|
||||
click(2);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(null);
|
||||
|
||||
click(3);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(FIRST);
|
||||
|
||||
|
||||
click(4);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(ALL);
|
||||
|
||||
setClickCountToStart(1);
|
||||
|
||||
click(1);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(null);
|
||||
|
||||
click(2);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(FIRST);
|
||||
|
||||
click(3);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(ALL);
|
||||
|
||||
setClickCountToStart(3);
|
||||
|
||||
click(1);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
assertEditing(false);
|
||||
|
||||
click(2);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
assertEditing(false);
|
||||
|
||||
click(3);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(null);
|
||||
|
||||
click(4);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(FIRST);
|
||||
|
||||
click(5);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(ALL);
|
||||
|
||||
|
||||
@ -123,11 +121,11 @@ public class bug6263446 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
assertEditing(true);
|
||||
|
||||
click(2);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
checkSelectedText(FIRST);
|
||||
|
||||
}
|
||||
|
@ -28,8 +28,6 @@
|
||||
@run main bug6777378
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
@ -43,7 +41,6 @@ public class bug6777378 {
|
||||
private static JTableHeader header;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -78,7 +75,7 @@ public class bug6777378 {
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Point point = header.getLocationOnScreen();
|
||||
robot.mouseMove(point.x + 20, point.y + 50);
|
||||
robot.mouseMove(point.x + 30, point.y + 50);
|
||||
|
@ -38,7 +38,6 @@ import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.JFrame;
|
||||
@ -49,7 +48,6 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import sun.awt.SunToolkit;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class bug7055065 {
|
||||
@ -57,7 +55,6 @@ public class bug7055065 {
|
||||
private static JTable table;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -67,15 +64,15 @@ public class bug7055065 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
clickCell(robot, 1, 1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
|
||||
KeyEvent.VK_BACK_SPACE);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
clickColumnHeader(robot, 1);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
clickColumnHeader(robot, 1);
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,6 @@
|
||||
@run main bug7068740
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.LayerUI;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
@ -43,7 +41,6 @@ public class bug7068740 extends JFrame {
|
||||
|
||||
private static Robot robot = null;
|
||||
private static JTable table = null;
|
||||
private static SunToolkit toolkit = null;
|
||||
|
||||
bug7068740() {
|
||||
super();
|
||||
@ -83,10 +80,6 @@ public class bug7068740 extends JFrame {
|
||||
robot.setAutoDelay(50);
|
||||
}
|
||||
|
||||
if (toolkit == null) {
|
||||
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -118,11 +111,11 @@ public class bug7068740 extends JFrame {
|
||||
}
|
||||
|
||||
private static void doTest() throws Exception {
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (getSelectedRow() != 19) {
|
||||
throw new RuntimeException("Test failed");
|
||||
@ -130,7 +123,7 @@ public class bug7068740 extends JFrame {
|
||||
|
||||
robot.keyPress(KeyEvent.VK_PAGE_UP);
|
||||
robot.keyRelease(KeyEvent.VK_PAGE_UP);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (getSelectedRow() != 0) {
|
||||
throw new RuntimeException("Test failed");
|
||||
}
|
||||
|
@ -28,8 +28,6 @@
|
||||
@run main bug6884066
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
@ -46,7 +44,6 @@ public class bug6884066 {
|
||||
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@ -62,7 +59,7 @@ public class bug6884066 {
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Point point = header.getLocationOnScreen();
|
||||
robot.mouseMove(point.x + 3, point.y + 3);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
|
@ -27,8 +27,6 @@
|
||||
@author Alexander Potochkin
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicTableHeaderUI;
|
||||
import javax.swing.table.JTableHeader;
|
||||
@ -37,7 +35,6 @@ import java.awt.*;
|
||||
public class bug6889007 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
|
||||
@ -59,7 +56,7 @@ public class bug6889007 {
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Point point = frame.getLocationOnScreen();
|
||||
int shift = 10;
|
||||
int x = point.x;
|
||||
@ -67,7 +64,7 @@ public class bug6889007 {
|
||||
for(int i = -shift; i < frame.getWidth() + 2*shift; i++) {
|
||||
robot.mouseMove(x++, y);
|
||||
}
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
// 9 is a magic test number
|
||||
if (MyTableHeaderUI.getTestValue() != 9) {
|
||||
throw new RuntimeException("Unexpected test number "
|
||||
|
@ -35,7 +35,6 @@ import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import javax.swing.text.BadLocationException;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4697612 {
|
||||
|
||||
@ -49,7 +48,6 @@ public class bug4697612 {
|
||||
private static JScrollPane scroller;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
@ -61,7 +59,7 @@ public class bug4697612 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -71,7 +69,7 @@ public class bug4697612 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// 4697612: pressing PgDn + PgUp should not alter caret position
|
||||
Util.hitKeys(robot, KeyEvent.VK_HOME);
|
||||
@ -102,11 +100,11 @@ public class bug4697612 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
|
||||
Util.hitKeys(robot, KeyEvent.VK_PAGE_UP);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
int pos = getTextCaretPosition();
|
||||
if (pos0 != pos) {
|
||||
@ -126,11 +124,11 @@ public class bug4697612 {
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_END);
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
pos0 = getScrollerViewPosition();
|
||||
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
int pos = getScrollerViewPosition();
|
||||
|
||||
@ -187,6 +185,7 @@ public class bug4697612 {
|
||||
private static void createAndShowGUI() {
|
||||
frame = new JFrame();
|
||||
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
|
||||
frame.setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
text = new JTextArea();
|
||||
|
@ -35,7 +35,6 @@ import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
import javax.accessibility.*;
|
||||
|
||||
public class bug8036819 {
|
||||
@ -49,15 +48,14 @@ public class bug8036819 {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
|
||||
Robot robo = new Robot();
|
||||
robo.setAutoDelay(300);
|
||||
robo.waitForIdle();
|
||||
|
||||
// Using mnemonic key to focus on the textfield
|
||||
Util.hitMnemonics(robo, KeyEvent.VK_P);
|
||||
toolkit.realSync();
|
||||
robo.waitForIdle();
|
||||
|
||||
if (!passed){
|
||||
throw new RuntimeException("Test failed.");
|
||||
|
@ -29,7 +29,6 @@
|
||||
*/
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4247996 {
|
||||
|
||||
@ -38,7 +37,6 @@ public class bug4247996 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -51,11 +49,11 @@ public class bug4247996 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = getButtonCenter();
|
||||
robot.mouseMove(point.x, point.y);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkButtonsSize();
|
||||
|
||||
|
@ -37,7 +37,6 @@ import java.awt.Toolkit;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.plaf.metal.MetalToolTipUI;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4846413 {
|
||||
|
||||
@ -46,7 +45,6 @@ public class bug4846413 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -59,11 +57,11 @@ public class bug4846413 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point movePoint = getButtonPoint();
|
||||
robot.mouseMove(movePoint.x, movePoint.y);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
long timeout = System.currentTimeMillis() + 9000;
|
||||
while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
|
||||
|
@ -34,7 +34,6 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4330357 {
|
||||
|
||||
@ -43,7 +42,6 @@ public class bug4330357 {
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -56,12 +54,12 @@ public class bug4330357 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouse(getTreeRowClickPoint(1));
|
||||
Util.hitKeys(robot, KeyEvent.VK_F2);
|
||||
Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_C);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!hasComponent(JTextField.class)) {
|
||||
throw new RuntimeException("Cell editor is missed for path: color");
|
||||
@ -69,11 +67,11 @@ public class bug4330357 {
|
||||
|
||||
|
||||
clickMouse(getButtonClickPoint());
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouse(getTreeRowClickPoint(2));
|
||||
Util.hitKeys(robot, KeyEvent.VK_F2);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!hasComponent(JComboBox.class)) {
|
||||
throw new RuntimeException("Cell editor is missed for path: sports");
|
||||
|
@ -36,7 +36,6 @@ import javax.swing.tree.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4908142 {
|
||||
|
||||
@ -44,7 +43,6 @@ public class bug4908142 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -55,7 +53,7 @@ public class bug4908142 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -65,7 +63,7 @@ public class bug4908142 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
@ -74,7 +72,7 @@ public class bug4908142 {
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
robot.keyPress(KeyEvent.VK_D);
|
||||
robot.keyRelease(KeyEvent.VK_D);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
String sel = Util.invokeOnEDT(new Callable<String>() {
|
||||
|
@ -33,7 +33,6 @@ import javax.swing.tree.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import sun.awt.*;
|
||||
|
||||
public class bug4927934 implements TreeSelectionListener, TreeExpansionListener, FocusListener {
|
||||
|
||||
@ -73,8 +72,7 @@ public class bug4927934 implements TreeSelectionListener, TreeExpansionListener,
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@ -97,35 +95,35 @@ public class bug4927934 implements TreeSelectionListener, TreeExpansionListener,
|
||||
// GO TO RIGHT
|
||||
selectionChanged = false;
|
||||
hitKey(KeyEvent.VK_RIGHT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!checkSelectionChanged(tree, 0)) {
|
||||
throw new RuntimeException("Root should be selected");
|
||||
}
|
||||
|
||||
selectionChanged = false;
|
||||
hitKey(KeyEvent.VK_RIGHT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!checkSelectionChanged(tree, 1)) {
|
||||
throw new RuntimeException("Node should be selected");
|
||||
}
|
||||
|
||||
treeExpanded = false;
|
||||
hitKey(KeyEvent.VK_RIGHT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!isTreeExpanded()) {
|
||||
throw new RuntimeException("Node should be expanded");
|
||||
}
|
||||
|
||||
selectionChanged = false;
|
||||
hitKey(KeyEvent.VK_RIGHT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!checkSelectionChanged(tree, 2)) {
|
||||
throw new RuntimeException("Leaf1 should be selected");
|
||||
}
|
||||
|
||||
selectionChanged = false;
|
||||
hitKey(KeyEvent.VK_RIGHT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!checkSelectionChanged(tree, 2)) {
|
||||
throw new RuntimeException("Leaf1 should be selected");
|
||||
}
|
||||
@ -133,7 +131,7 @@ public class bug4927934 implements TreeSelectionListener, TreeExpansionListener,
|
||||
// GO TO LEFT
|
||||
selectionChanged = false;
|
||||
hitKey(KeyEvent.VK_LEFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!checkSelectionChanged(tree, 1)) {
|
||||
throw new RuntimeException("Node should be selected");
|
||||
}
|
||||
@ -146,14 +144,14 @@ public class bug4927934 implements TreeSelectionListener, TreeExpansionListener,
|
||||
|
||||
selectionChanged = false;
|
||||
hitKey(KeyEvent.VK_LEFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!checkSelectionChanged(tree, 0)) {
|
||||
throw new RuntimeException("Root should be selected");
|
||||
}
|
||||
|
||||
treeCollapsed = false;
|
||||
hitKey(KeyEvent.VK_LEFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
if (!isTreeCollapsed()) {
|
||||
throw new RuntimeException("Root should be collapsed");
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import java.awt.event.InputEvent;
|
||||
import java.lang.reflect.Field;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6263446 {
|
||||
|
||||
@ -42,10 +41,8 @@ public class bug6263446 {
|
||||
private static final String ALL = FIRST + " " + SECOND;
|
||||
private static JTree tree;
|
||||
private static Robot robot;
|
||||
private static SunToolkit toolkit;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -56,7 +53,7 @@ public class bug6263446 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = getClickPoint();
|
||||
robot.mouseMove(point.x, point.y);
|
||||
@ -182,7 +179,7 @@ public class bug6263446 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
}
|
||||
|
||||
@ -252,7 +249,7 @@ public class bug6263446 {
|
||||
}
|
||||
|
||||
private static void assertEditingNoTreeLock(final boolean editing) throws Exception {
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.InputEvent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
@ -42,14 +41,12 @@ import javax.swing.event.TreeExpansionListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6505523 {
|
||||
|
||||
private static JTree tree;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -61,14 +58,14 @@ public class bug6505523 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = getRowPointToClick(2);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
}
|
||||
|
||||
@ -129,4 +126,4 @@ public class bug6505523 {
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
80
jdk/test/javax/swing/JTree/6578666/bug6578666.java
Normal file
80
jdk/test/javax/swing/JTree/6578666/bug6578666.java
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 6578666
|
||||
* @summary REGRESSION: Exception occurs when updateUI for JTree is triggered by KeyEvent
|
||||
* @run main bug6578666
|
||||
* @author Alexander Potochkin
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6578666 {
|
||||
|
||||
private static JTree tree;
|
||||
|
||||
private static void createGui() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
tree = new JTree();
|
||||
frame.add(tree);
|
||||
|
||||
tree.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
tree.updateUI();
|
||||
}
|
||||
});
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bug6578666.createGui();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
tree.requestFocus();
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
|
||||
}
|
||||
}
|
@ -26,17 +26,16 @@
|
||||
* @bug 8003400
|
||||
* @summary Tests that JTree shows the last row
|
||||
* @author Sergey Malenkov
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build ExtendedRobot
|
||||
* @run main/othervm Test8003400
|
||||
* @run main/othervm Test8003400 reverse
|
||||
* @run main/othervm Test8003400 system
|
||||
* @run main/othervm Test8003400 system reverse
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -85,10 +84,12 @@ public class Test8003400 {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
toolkit.realSync(500);
|
||||
new Robot().keyPress(KeyEvent.VK_END);
|
||||
toolkit.realSync(500);
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.waitForIdle(500);
|
||||
robot.keyPress(KeyEvent.VK_END);
|
||||
robot.waitForIdle(500);
|
||||
robot.keyRelease(KeyEvent.VK_END);
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -36,7 +36,6 @@ import java.awt.event.InputEvent;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import sun.awt.SunToolkit;
|
||||
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
|
||||
import com.sun.java.swing.plaf.windows.WindowsTreeUI;
|
||||
|
||||
@ -47,7 +46,6 @@ public class bug8004298 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
try {
|
||||
UIManager.setLookAndFeel(new WindowsLookAndFeel());
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ulafe) {
|
||||
@ -63,7 +61,7 @@ public class bug8004298 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = Util.invokeOnEDT(new Callable<Point>() {
|
||||
|
||||
@ -81,7 +79,7 @@ public class bug8004298 {
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,6 @@ public class TaskbarPositionTest extends JFrame implements ActionListener {
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
|
||||
sun.awt.SunToolkit toolkit = (sun.awt.SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
@ -275,7 +274,7 @@ public class TaskbarPositionTest extends JFrame implements ActionListener {
|
||||
// 1 - menu
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_1);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
isPopupOnScreen(menu1.getPopupMenu(), screenBounds);
|
||||
|
||||
// 2 menu with sub menu
|
||||
@ -283,14 +282,14 @@ public class TaskbarPositionTest extends JFrame implements ActionListener {
|
||||
robot.keyRelease(KeyEvent.VK_RIGHT);
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_S);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
isPopupOnScreen(menu2.getPopupMenu(), screenBounds);
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
|
||||
// Focus should go to non editable combo box
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(500);
|
||||
|
||||
robot.keyPress(KeyEvent.VK_DOWN);
|
||||
@ -320,7 +319,7 @@ public class TaskbarPositionTest extends JFrame implements ActionListener {
|
||||
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
test.setLocation(-30, 100);
|
||||
@ -334,7 +333,7 @@ public class TaskbarPositionTest extends JFrame implements ActionListener {
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(500);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class NonOpaquePopupMenuTest extends JFrame {
|
||||
|
||||
@ -53,7 +52,6 @@ public class NonOpaquePopupMenuTest extends JFrame {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
|
||||
@ -65,14 +63,14 @@ public class NonOpaquePopupMenuTest extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point p = getMenuClickPoint();
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (isParentOpaque()) {
|
||||
throw new RuntimeException("Popup menu parent is opaque");
|
||||
|
@ -34,7 +34,6 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4917669 {
|
||||
|
||||
@ -42,7 +41,6 @@ public class bug4917669 {
|
||||
private static JFrame mainFrame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
|
||||
@ -54,7 +52,7 @@ public class bug4917669 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@ -64,10 +62,10 @@ public class bug4917669 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_O);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Action did not received by menu item.");
|
||||
|
@ -27,8 +27,6 @@
|
||||
@author Pavel Porvatov
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
@ -82,9 +80,9 @@ public class bug7146377 {
|
||||
}
|
||||
});
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
// On Linux platforms realSync doesn't guaranties setSize completion
|
||||
Thread.sleep(1000);
|
||||
@ -95,7 +93,6 @@ public class bug7146377 {
|
||||
}
|
||||
});
|
||||
|
||||
Robot robot = new Robot();
|
||||
|
||||
robot.setAutoDelay(200);
|
||||
|
||||
@ -117,7 +114,7 @@ public class bug7146377 {
|
||||
robot.mouseRelease(button);
|
||||
}
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -29,8 +29,6 @@
|
||||
* @run main Test6256140
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
@ -46,14 +44,13 @@ public class Test6256140 {
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = ft.getLocationOnScreen();
|
||||
robot.mouseMove(point.x, point.y);
|
||||
@ -61,7 +58,7 @@ public class Test6256140 {
|
||||
|
||||
robot.keyPress(KeyEvent.VK_A);
|
||||
robot.keyRelease(KeyEvent.VK_A);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!isTooltipShowning()) {
|
||||
throw new RuntimeException("Tooltip is not shown");
|
||||
@ -69,7 +66,7 @@ public class Test6256140 {
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (isTooltipShowning()) {
|
||||
throw new RuntimeException("Tooltip must be hidden now");
|
||||
@ -81,7 +78,7 @@ public class Test6256140 {
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!isTextEqual()) {
|
||||
throw new RuntimeException("FormattedTextField must cancel the updated value");
|
||||
|
@ -28,8 +28,6 @@
|
||||
@run main bug7171812
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.dnd.*;
|
||||
import java.awt.event.InputEvent;
|
||||
@ -45,7 +43,6 @@ public class bug7171812 {
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws Exception{
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
@ -53,10 +50,10 @@ public class bug7171812 {
|
||||
setupGUI();
|
||||
}
|
||||
});
|
||||
toolkit.realSync();
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.waitForIdle();
|
||||
robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) {
|
||||
|
@ -32,14 +32,11 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug4251579 {
|
||||
|
||||
private static JLabel htmlComponent;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -51,7 +48,7 @@ public class bug4251579 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
@run main bug4983388
|
||||
*/
|
||||
|
||||
import sun.awt.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.MenuListener;
|
||||
@ -64,7 +63,6 @@ public class bug4983388 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
|
||||
} catch (UnsupportedLookAndFeelException | ClassNotFoundException ex) {
|
||||
@ -78,9 +76,10 @@ public class bug4983388 {
|
||||
});
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_F);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
if (!bMenuSelected) {
|
||||
throw new RuntimeException("shortcuts on menus do not work");
|
||||
|
@ -29,8 +29,6 @@
|
||||
* @run main bug8023474
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
@ -45,7 +43,6 @@ public class bug8023474 {
|
||||
private static JTree tree;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -55,14 +52,14 @@ public class bug8023474 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = getRowPointToClick(1);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Boolean result = (Boolean)tree.getCellEditor().getCellEditorValue();
|
||||
if (!result) {
|
||||
|
@ -28,8 +28,6 @@
|
||||
@author Pavel Porvatov
|
||||
*/
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicComboPopup;
|
||||
import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||
@ -82,7 +80,7 @@ public class bug7158712 {
|
||||
}
|
||||
});
|
||||
|
||||
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point comboBoxLocation = Util.invokeOnEDT(new Callable<Point>() {
|
||||
@Override
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user