mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-04 20:18:49 +00:00
8234149: Several regression tests do not dispose Frame at end
Reviewed-by: serb
This commit is contained in:
parent
0ee193c705
commit
55f3fd95e6
@ -43,53 +43,58 @@ public class bug6711682 {
|
||||
private static JCheckBox editorCb;
|
||||
private static JCheckBox rendererCb;
|
||||
private static JTable table;
|
||||
private static JFrame f;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point l = table.getLocationOnScreen();
|
||||
int h = table.getRowHeight();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point l = table.getLocationOnScreen();
|
||||
int h = table.getRowHeight();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
// Without pressing F2 the last table's cell
|
||||
// reported <code>false</code> value
|
||||
// note that I can't press it inside the for loop
|
||||
// because it doesn't reproduce the bug
|
||||
robot.keyPress(KeyEvent.VK_F2);
|
||||
robot.keyRelease(KeyEvent.VK_F2);
|
||||
// Without pressing F2 the last table's cell
|
||||
// reported <code>false</code> value
|
||||
// note that I can't press it inside the for loop
|
||||
// because it doesn't reproduce the bug
|
||||
robot.keyPress(KeyEvent.VK_F2);
|
||||
robot.keyRelease(KeyEvent.VK_F2);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!Boolean.TRUE.equals(table.getValueAt(i, 0))) {
|
||||
throw new RuntimeException("Row #" + i + " checkbox is not selected");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!Boolean.TRUE.equals(table.getValueAt(i, 0))) {
|
||||
throw new RuntimeException("Row #" + i + " checkbox is not selected");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
robot.keyPress(KeyEvent.VK_F2);
|
||||
robot.keyRelease(KeyEvent.VK_F2);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (Boolean.TRUE.equals(table.getValueAt(i, 0))) {
|
||||
throw new RuntimeException("Row #" + i + " checkbox is selected");
|
||||
for (int i = 2; i >= 0; i--) {
|
||||
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
robot.keyPress(KeyEvent.VK_F2);
|
||||
robot.keyRelease(KeyEvent.VK_F2);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (Boolean.TRUE.equals(table.getValueAt(i, 0))) {
|
||||
throw new RuntimeException("Row #" + i + " checkbox is selected");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (f != null) SwingUtilities.invokeAndWait(() -> f.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
editorCb = new JCheckBox();
|
||||
rendererCb = new JCheckBox();
|
||||
JFrame f = new JFrame("Table with CheckBox");
|
||||
f = new JFrame("Table with CheckBox");
|
||||
Container p = f.getContentPane();
|
||||
p.setLayout(new BorderLayout());
|
||||
table = new JTable(new Object[][]{{false}, {false}, {false}}, new Object[]{"CheckBox"});
|
||||
|
||||
@ -45,10 +45,15 @@ public class bug8133039 {
|
||||
|
||||
private static volatile int ACTION_PERFORMED_CALLS = 0;
|
||||
private static volatile int ACTION_ACCEPTED_CALLS = 0;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
testActionNotification();
|
||||
testPopupAction();
|
||||
try {
|
||||
testActionNotification();
|
||||
testPopupAction();
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void testActionNotification() {
|
||||
@ -114,7 +119,7 @@ public class bug8133039 {
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setSize(300, 300);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
|
||||
@ -36,9 +36,10 @@ import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug4368790 {
|
||||
private static JButton b1;
|
||||
private static JFrame frame;
|
||||
|
||||
private static void createGui() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setLayout(new FlowLayout());
|
||||
|
||||
@ -53,21 +54,25 @@ public class bug4368790 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bug4368790.createGui();
|
||||
try {
|
||||
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");
|
||||
}
|
||||
});
|
||||
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");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4796987
|
||||
* @key headful
|
||||
* @requires (os.family == "windows")
|
||||
* @summary XP Only: JButton.setBorderPainted() does not work with XP L&F
|
||||
* @author Alexander Scherbatiy
|
||||
@ -46,12 +47,17 @@ public class bug4796987 {
|
||||
|
||||
private static JButton button1;
|
||||
private static JButton button2;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (Platform.isWindows()
|
||||
try {
|
||||
if (Platform.isWindows()
|
||||
&& OSVersion.current().equals(OSVersion.WINDOWS_XP)) {
|
||||
UIManager.setLookAndFeel(new WindowsLookAndFeel());
|
||||
testButtonBorder();
|
||||
UIManager.setLookAndFeel(new WindowsLookAndFeel());
|
||||
testButtonBorder();
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +95,7 @@ public class bug4796987 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("Test");
|
||||
frame = new JFrame("Test");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(200, 200);
|
||||
|
||||
|
||||
@ -56,11 +56,16 @@ public class Test8051548 {
|
||||
private static JColorChooser colorChooser;
|
||||
private static boolean propertyChangeListenerInvoked;
|
||||
private static volatile Color color;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
testColorPanels();
|
||||
testShowDialog(true);
|
||||
testShowDialog(false);
|
||||
try {
|
||||
testColorPanels();
|
||||
testShowDialog(true);
|
||||
testShowDialog(false);
|
||||
} finally {
|
||||
if(frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void testColorPanels() throws Exception {
|
||||
@ -182,7 +187,7 @@ public class Test8051548 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setSize(700, 500);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
colorChooser = new JColorChooser();
|
||||
|
||||
@ -43,7 +43,7 @@ import java.awt.event.*;
|
||||
|
||||
public class bug4523758 {
|
||||
|
||||
private JFrame frame;
|
||||
private static JFrame frame;
|
||||
private JToolBar tools;
|
||||
private JComboBox combo;
|
||||
|
||||
@ -153,13 +153,15 @@ public class bug4523758 {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
bug4523758 test = new bug4523758();
|
||||
test.doTest();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("FAIL");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,14 +46,18 @@ public class bug6236162 {
|
||||
private static MyComboUI comboUI;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
test();
|
||||
System.out.println("Test passed");
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
test();
|
||||
System.out.println("Test passed");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
|
||||
@ -42,43 +42,48 @@ import static javax.swing.SwingUtilities.invokeAndWait;
|
||||
*/
|
||||
|
||||
public class Test7195179 {
|
||||
private static JFrame frame;
|
||||
public static void main(String[] args) throws Exception {
|
||||
invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Integer[] items = {null, 1, 2, 3};
|
||||
JComboBox<Integer> combo = new JComboBox<>(items);
|
||||
JLabel label = new JLabel("choose:");
|
||||
JPanel panel = new JPanel();
|
||||
GroupLayout layout = new GroupLayout(panel);
|
||||
panel.setLayout(layout);
|
||||
label.setLabelFor(combo);
|
||||
combo.setSelectedIndex(0);
|
||||
combo.setRenderer(new ListCellRenderer<Integer>() {
|
||||
private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();
|
||||
try {
|
||||
Integer[] items = {null, 1, 2, 3};
|
||||
JComboBox<Integer> combo = new JComboBox<>(items);
|
||||
JLabel label = new JLabel("choose:");
|
||||
JPanel panel = new JPanel();
|
||||
GroupLayout layout = new GroupLayout(panel);
|
||||
panel.setLayout(layout);
|
||||
label.setLabelFor(combo);
|
||||
combo.setSelectedIndex(0);
|
||||
combo.setRenderer(new ListCellRenderer<Integer>() {
|
||||
private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
layout.setAutoCreateContainerGaps(true);
|
||||
layout.setAutoCreateGaps(true);
|
||||
layout.setHorizontalGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup().addComponent(label))
|
||||
.addGroup(layout.createParallelGroup().addComponent(combo)));
|
||||
layout.setVerticalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addGroup(layout
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
layout.setAutoCreateContainerGaps(true);
|
||||
layout.setAutoCreateGaps(true);
|
||||
layout.setHorizontalGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup().addComponent(label))
|
||||
.addGroup(layout.createParallelGroup().addComponent(combo)));
|
||||
layout.setVerticalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addGroup(layout
|
||||
.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(label)
|
||||
.addComponent(combo)));
|
||||
|
||||
JFrame frame = new JFrame(getClass().getSimpleName());
|
||||
frame.add(panel);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
frame = new JFrame(getClass().getSimpleName());
|
||||
frame.add(panel);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
} finally {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -43,13 +43,14 @@ import javax.swing.WindowConstants;
|
||||
public class bug8057893 {
|
||||
|
||||
private static volatile boolean isComboBoxEdited = false;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"});
|
||||
comboBox.setEditable(true);
|
||||
@ -76,6 +77,7 @@ public class bug8057893 {
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (frame != null) EventQueue.invokeAndWait(() -> frame.dispose());
|
||||
if(!isComboBoxEdited){
|
||||
throw new RuntimeException("ComboBoxEdited event is not fired!");
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class bug4337267 {
|
||||
TestJPanel p1, p2;
|
||||
TestBufferedImage i1, i2;
|
||||
JComponent[] printq;
|
||||
JFrame window;
|
||||
static JFrame window;
|
||||
static boolean testFailed = false;
|
||||
static boolean done = false;
|
||||
|
||||
@ -246,33 +246,36 @@ public class bug4337267 {
|
||||
Graphics g0 = image.getGraphics();
|
||||
super.paint(g0);
|
||||
g.drawImage(image, 0, 0, this);
|
||||
}
|
||||
}
|
||||
} }
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
final bug4337267 test = new bug4337267();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
test.run();
|
||||
}
|
||||
});
|
||||
try {
|
||||
final bug4337267 test = new bug4337267();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
test.run();
|
||||
}
|
||||
});
|
||||
|
||||
synchronized(test) {
|
||||
while (!done) {
|
||||
try {
|
||||
test.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
// do nothing
|
||||
synchronized(test) {
|
||||
while (!done) {
|
||||
try {
|
||||
test.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (testFailed) {
|
||||
throw new RuntimeException("FAIL");
|
||||
}
|
||||
if (testFailed) {
|
||||
throw new RuntimeException("FAIL");
|
||||
}
|
||||
|
||||
System.out.println("OK");
|
||||
System.out.println("OK");
|
||||
} finally {
|
||||
if (window != null) SwingUtilities.invokeAndWait(() -> window.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,68 +36,73 @@ import java.awt.*;
|
||||
public class bug6989617 {
|
||||
private static MyPanel panel;
|
||||
private static JButton button;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
JFrame frame = new JFrame();
|
||||
frame. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
panel = new MyPanel();
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame();
|
||||
frame. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
panel = new MyPanel();
|
||||
|
||||
button = new JButton("Hello");
|
||||
panel.add(button);
|
||||
frame.add(panel);
|
||||
button = new JButton("Hello");
|
||||
panel.add(button);
|
||||
frame.add(panel);
|
||||
|
||||
frame.setSize(200, 300);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
// Testing the panel as a painting origin,
|
||||
// the panel.paintImmediately() must be triggered
|
||||
// when button.repaint() is called
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
panel.resetPaintRectangle();
|
||||
button.repaint();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Rectangle pr = panel.getPaintRectangle();
|
||||
if (!pr.getSize().equals(button.getSize())) {
|
||||
throw new RuntimeException("wrong size of the dirty area");
|
||||
frame.setSize(200, 300);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
if (!pr.getLocation().equals(button.getLocation())) {
|
||||
throw new RuntimeException("wrong location of the dirty area");
|
||||
});
|
||||
// Testing the panel as a painting origin,
|
||||
// the panel.paintImmediately() must be triggered
|
||||
// when button.repaint() is called
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
panel.resetPaintRectangle();
|
||||
button.repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
// Testing the panel as NOT a painting origin
|
||||
// the panel.paintImmediately() must NOT be triggered
|
||||
// when button.repaint() is called
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
panel.resetPaintRectangle();
|
||||
panel.setPaintingOrigin(false);
|
||||
if (panel.getPaintRectangle() != null) {
|
||||
throw new RuntimeException("paint rectangle is not null");
|
||||
});
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Rectangle pr = panel.getPaintRectangle();
|
||||
if (!pr.getSize().equals(button.getSize())) {
|
||||
throw new RuntimeException("wrong size of the dirty area");
|
||||
}
|
||||
if (!pr.getLocation().equals(button.getLocation())) {
|
||||
throw new RuntimeException("wrong location of the dirty area");
|
||||
}
|
||||
}
|
||||
button.repaint();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if(panel.getPaintRectangle() != null) {
|
||||
throw new RuntimeException("paint rectangle is not null");
|
||||
});
|
||||
// Testing the panel as NOT a painting origin
|
||||
// the panel.paintImmediately() must NOT be triggered
|
||||
// when button.repaint() is called
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
panel.resetPaintRectangle();
|
||||
panel.setPaintingOrigin(false);
|
||||
if (panel.getPaintRectangle() != null) {
|
||||
throw new RuntimeException("paint rectangle is not null");
|
||||
}
|
||||
button.repaint();
|
||||
}
|
||||
System.out.println("Test passed...");
|
||||
}
|
||||
});
|
||||
});
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if(panel.getPaintRectangle() != null) {
|
||||
throw new RuntimeException("paint rectangle is not null");
|
||||
}
|
||||
System.out.println("Test passed...");
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
static class MyPanel extends JPanel {
|
||||
|
||||
@ -56,115 +56,119 @@ import java.awt.image.BufferedImage;
|
||||
public class bug7154030 {
|
||||
|
||||
private static JButton button = null;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
BufferedImage imageInit = null;
|
||||
try {
|
||||
BufferedImage imageInit = null;
|
||||
|
||||
BufferedImage imageShow = null;
|
||||
BufferedImage imageShow = null;
|
||||
|
||||
BufferedImage imageHide = null;
|
||||
BufferedImage imageHide = null;
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JDesktopPane desktop = new JDesktopPane();
|
||||
button = new JButton("button");
|
||||
JFrame frame = new JFrame();
|
||||
@Override
|
||||
public void run() {
|
||||
JDesktopPane desktop = new JDesktopPane();
|
||||
button = new JButton("button");
|
||||
frame = new JFrame();
|
||||
|
||||
button.setSize(200, 200);
|
||||
button.setLocation(100, 100);
|
||||
button.setForeground(Color.RED);
|
||||
button.setBackground(Color.RED);
|
||||
button.setOpaque(true);
|
||||
button.setVisible(false);
|
||||
desktop.add(button);
|
||||
button.setSize(200, 200);
|
||||
button.setLocation(100, 100);
|
||||
button.setForeground(Color.RED);
|
||||
button.setBackground(Color.RED);
|
||||
button.setOpaque(true);
|
||||
button.setVisible(false);
|
||||
desktop.add(button);
|
||||
|
||||
frame.setContentPane(desktop);
|
||||
frame.setSize(300, 300);
|
||||
frame.setLocation(0, 0);
|
||||
frame.setVisible(true);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setContentPane(desktop);
|
||||
frame.setSize(300, 300);
|
||||
frame.setLocation(0, 0);
|
||||
frame.setVisible(true);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle(500);
|
||||
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.show();
|
||||
}
|
||||
});
|
||||
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle(500);
|
||||
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
button.hide();
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.show();
|
||||
robot.waitForIdle(500);
|
||||
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
if (!Util.compareBufferedImages(imageInit, imageHide)) {
|
||||
throw new Exception("Failed to hide opaque button");
|
||||
}
|
||||
});
|
||||
|
||||
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");
|
||||
}
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
robot.waitForIdle();
|
||||
@Override
|
||||
public void run() {
|
||||
button.setOpaque(false);
|
||||
button.setBackground(new Color(128, 128, 0));
|
||||
button.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
robot.waitForIdle(500);
|
||||
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.hide();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.show();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle(500);
|
||||
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (Util.compareBufferedImages(imageInit, imageShow)) {
|
||||
throw new Exception("Failed to show non-opaque button");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle(500);
|
||||
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
robot.waitForIdle(500);
|
||||
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
if (!Util.compareBufferedImages(imageInit, imageHide)) {
|
||||
throw new Exception("Failed to hide opaque button");
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.setOpaque(false);
|
||||
button.setBackground(new Color(128, 128, 0));
|
||||
button.setVisible(false);
|
||||
if (!Util.compareBufferedImages(imageInit, imageHide)) {
|
||||
throw new Exception("Failed to hide non-opaque button");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle(500);
|
||||
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.show();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle(500);
|
||||
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
button.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (Util.compareBufferedImages(imageInit, imageShow)) {
|
||||
throw new Exception("Failed to show non-opaque button");
|
||||
}
|
||||
|
||||
robot.waitForIdle(500);
|
||||
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
|
||||
|
||||
if (!Util.compareBufferedImages(imageInit, imageHide)) {
|
||||
throw new Exception("Failed to hide non-opaque button");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,36 +42,40 @@ public class bug4492274 {
|
||||
|
||||
private static JEditorPane jep;
|
||||
|
||||
private static JFrame f;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
Robot robot = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
page = new URL(page, "#linkname");
|
||||
jep.setPage(page);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
page = new URL(page, "#linkname");
|
||||
jep.setPage(page);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
if (getPageAnchor() == null) {
|
||||
throw new RuntimeException("JEditorPane.getPage() returns null anchor reference");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
if (getPageAnchor() == null) {
|
||||
throw new RuntimeException("JEditorPane.getPage() returns null anchor reference");
|
||||
} finally {
|
||||
if (f != null) SwingUtilities.invokeAndWait(() -> f.dispose());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String getPageAnchor() throws Exception {
|
||||
@ -92,7 +96,7 @@ public class bug4492274 {
|
||||
File file = new File(System.getProperty("test.src", "."), "test.html");
|
||||
page = file.toURI().toURL();
|
||||
|
||||
JFrame f = new JFrame();
|
||||
f = new JFrame();
|
||||
|
||||
jep = new JEditorPane();
|
||||
jep.setEditorKit(new HTMLEditorKit());
|
||||
|
||||
@ -39,17 +39,21 @@ public class bug4962534 {
|
||||
Robot robot;
|
||||
volatile Point framePosition;
|
||||
volatile Point newFrameLocation;
|
||||
JFrame frame;
|
||||
static JFrame frame;
|
||||
Rectangle gcBounds;
|
||||
Component titleComponent;
|
||||
JLayeredPane lPane;
|
||||
volatile boolean titleFound = false;
|
||||
public static Object LOCK = new Object();
|
||||
|
||||
public static void main(final String[] args) {
|
||||
bug4962534 app = new bug4962534();
|
||||
app.init();
|
||||
app.start();
|
||||
public static void main(final String[] args) throws Exception {
|
||||
try {
|
||||
bug4962534 app = new bug4962534();
|
||||
app.init();
|
||||
app.start();
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
@ -42,46 +42,49 @@ public class ScaledFrameBackgroundTest {
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(400, 300);
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(BACKGROUND);
|
||||
frame.getContentPane().add(panel);
|
||||
frame.setVisible(true);
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(400, 300);
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(BACKGROUND);
|
||||
frame.getContentPane().add(panel);
|
||||
frame.setVisible(true);
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(200);
|
||||
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(200);
|
||||
Rectangle[] rects = new Rectangle[1];
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
rects[0] = frame.getBounds();
|
||||
});
|
||||
|
||||
Rectangle[] rects = new Rectangle[1];
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
rects[0] = frame.getBounds();
|
||||
});
|
||||
Rectangle bounds = rects[0];
|
||||
|
||||
Rectangle bounds = rects[0];
|
||||
int x = bounds.x + bounds.width / 4;
|
||||
int y = bounds.y + bounds.height / 4;
|
||||
|
||||
int x = bounds.x + bounds.width / 4;
|
||||
int y = bounds.y + bounds.height / 4;
|
||||
Color color = robot.getPixelColor(x, y);
|
||||
|
||||
Color color = robot.getPixelColor(x, y);
|
||||
if (!BACKGROUND.equals(color)) {
|
||||
throw new RuntimeException("Wrong backgound color!");
|
||||
}
|
||||
|
||||
if (!BACKGROUND.equals(color)) {
|
||||
throw new RuntimeException("Wrong backgound color!");
|
||||
}
|
||||
x = bounds.x + 3 * bounds.width / 4;
|
||||
y = bounds.y + 3 * bounds.height / 4;
|
||||
|
||||
x = bounds.x + 3 * bounds.width / 4;
|
||||
y = bounds.y + 3 * bounds.height / 4;
|
||||
color = robot.getPixelColor(x, y);
|
||||
|
||||
color = robot.getPixelColor(x, y);
|
||||
|
||||
if (!BACKGROUND.equals(color)) {
|
||||
throw new RuntimeException("Wrong backgound color!");
|
||||
if (!BACKGROUND.equals(color)) {
|
||||
throw new RuntimeException("Wrong backgound color!");
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,20 +39,24 @@ public class bug5066752
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot r = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
try {
|
||||
Robot r = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
r.waitForIdle();
|
||||
|
||||
r.delay(600);
|
||||
|
||||
Point p = Util.getCenterPoint(frame);
|
||||
Color color = r.getPixelColor((int) p.getX(), (int) p.getY());
|
||||
if (!color.equals(Color.RED)) {
|
||||
throw new Exception("Test failed: JDesktopPane isn't transparent. Expected color is (red color): " + Color.RED + ", actual color is: " + color);
|
||||
}
|
||||
});
|
||||
r.waitForIdle();
|
||||
|
||||
r.delay(600);
|
||||
|
||||
Point p = Util.getCenterPoint(frame);
|
||||
Color color = r.getPixelColor((int) p.getX(), (int) p.getY());
|
||||
if (!color.equals(Color.RED)) {
|
||||
throw new Exception("Test failed: JDesktopPane isn't transparent. Expected color is (red color): " + Color.RED + ", actual color is: " + color);
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,32 +53,35 @@ public class JInternalFrameDraggingTest {
|
||||
private static Color BACKGROUND_COLOR = Color.ORANGE;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
SwingUtilities.invokeAndWait(JInternalFrameDraggingTest::createAndShowGUI);
|
||||
robot.waitForIdle();
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
SwingUtilities.invokeAndWait(JInternalFrameDraggingTest::createAndShowGUI);
|
||||
robot.waitForIdle();
|
||||
final int translate = FRAME_SIZE / 4;
|
||||
moveFrame(robot, translate, translate / 2, translate / 2);
|
||||
robot.waitForIdle();
|
||||
|
||||
final int translate = FRAME_SIZE / 4;
|
||||
moveFrame(robot, translate, translate / 2, translate / 2);
|
||||
robot.waitForIdle();
|
||||
Point p = getDesktopPaneLocation();
|
||||
int size = translate / 2;
|
||||
Rectangle rect = new Rectangle(p.x, p.y, size, size);
|
||||
BufferedImage img = robot.createScreenCapture(rect);
|
||||
|
||||
Point p = getDesktopPaneLocation();
|
||||
int size = translate / 2;
|
||||
Rectangle rect = new Rectangle(p.x, p.y, size, size);
|
||||
BufferedImage img = robot.createScreenCapture(rect);
|
||||
|
||||
int testRGB = BACKGROUND_COLOR.getRGB();
|
||||
for (int i = 1; i < size; i++) {
|
||||
int rgbCW = img.getRGB(i, size / 2);
|
||||
int rgbCH = img.getRGB(size / 2, i);
|
||||
if (rgbCW != testRGB || rgbCH != testRGB) {
|
||||
System.out.println("i " + i + " rgbCW " +
|
||||
Integer.toHexString(rgbCW) +
|
||||
" testRGB " + Integer.toHexString(testRGB) +
|
||||
" rgbCH " + Integer.toHexString(rgbCH));
|
||||
throw new RuntimeException("Background color is wrong!");
|
||||
int testRGB = BACKGROUND_COLOR.getRGB();
|
||||
for (int i = 1; i < size; i++) {
|
||||
int rgbCW = img.getRGB(i, size / 2);
|
||||
int rgbCH = img.getRGB(size / 2, i);
|
||||
if (rgbCW != testRGB || rgbCH != testRGB) {
|
||||
System.out.println("i " + i + " rgbCW " +
|
||||
Integer.toHexString(rgbCW) +
|
||||
" testRGB " + Integer.toHexString(testRGB) +
|
||||
" rgbCH " + Integer.toHexString(rgbCH));
|
||||
throw new RuntimeException("Background color is wrong!");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,35 +40,40 @@ public class InternalFrameIsNotCollectedTest {
|
||||
public static final int waitTime = 5000;
|
||||
private static Robot robot;
|
||||
private static CustomInternalFrame iFrame;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
initRobot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initUI();
|
||||
try {
|
||||
closeInternalFrame();
|
||||
} catch (PropertyVetoException e) {
|
||||
throw new RuntimeException(e);
|
||||
try {
|
||||
initRobot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initUI();
|
||||
try {
|
||||
closeInternalFrame();
|
||||
} catch (PropertyVetoException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
invokeGC();
|
||||
System.runFinalization();
|
||||
Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later
|
||||
Date startWaiting = new Date();
|
||||
synchronized (CustomInternalFrame.waiter) {
|
||||
// Sync with finalization thread.
|
||||
Date now = new Date();
|
||||
while (now.getTime() - startWaiting.getTime() < maxWaitTime && !CustomInternalFrame.finalized) {
|
||||
CustomInternalFrame.waiter.wait(waitTime);
|
||||
now = new Date();
|
||||
}
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
invokeGC();
|
||||
System.runFinalization();
|
||||
Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later
|
||||
Date startWaiting = new Date();
|
||||
synchronized (CustomInternalFrame.waiter) {
|
||||
// Sync with finalization thread.
|
||||
Date now = new Date();
|
||||
while (now.getTime() - startWaiting.getTime() < maxWaitTime && !CustomInternalFrame.finalized) {
|
||||
CustomInternalFrame.waiter.wait(waitTime);
|
||||
now = new Date();
|
||||
if (!CustomInternalFrame.finalized) {
|
||||
throw new RuntimeException("Closed internal frame wasn't collected");
|
||||
}
|
||||
}
|
||||
if (!CustomInternalFrame.finalized) {
|
||||
throw new RuntimeException("Closed internal frame wasn't collected");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +88,7 @@ public class InternalFrameIsNotCollectedTest {
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
JFrame frame = new JFrame("Internal Frame Test");
|
||||
frame = new JFrame("Internal Frame Test");
|
||||
frame.getContentPane().setLayout(new BorderLayout());
|
||||
JDesktopPane desktopPane = new JDesktopPane();
|
||||
desktopPane.setDesktopManager(new DefaultDesktopManager());
|
||||
|
||||
@ -49,65 +49,69 @@ public class bug6596966 {
|
||||
private static JComboBox comboBox;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
button = new JButton("Button");
|
||||
comboBox = new JComboBox();
|
||||
|
||||
label = new JLabel("Label");
|
||||
label.setDisplayedMnemonic('L');
|
||||
label.setLabelFor(comboBox);
|
||||
|
||||
JPanel pnContent = new JPanel();
|
||||
|
||||
pnContent.add(button);
|
||||
pnContent.add(label);
|
||||
pnContent.add(comboBox);
|
||||
|
||||
frame = new JFrame();
|
||||
|
||||
frame.add(pnContent);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
int keyMask = InputEvent.ALT_MASK;
|
||||
if (Platform.isOSX()) {
|
||||
keyMask = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
|
||||
}
|
||||
ArrayList<Integer> keys = Util.getKeyCodesFromKeyMask(keyMask);
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
robot.keyPress(keys.get(i));
|
||||
}
|
||||
|
||||
robot.keyPress(KeyEvent.VK_L);
|
||||
|
||||
robot.waitForIdle();
|
||||
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
|
||||
EventQueue.getMostRecentEventTime(), 0, KeyEvent.VK_L, 'L'));
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (!comboBox.isFocusOwner()) {
|
||||
throw new RuntimeException("comboBox isn't focus owner");
|
||||
}
|
||||
button = new JButton("Button");
|
||||
comboBox = new JComboBox();
|
||||
|
||||
label = new JLabel("Label");
|
||||
label.setDisplayedMnemonic('L');
|
||||
label.setLabelFor(comboBox);
|
||||
|
||||
JPanel pnContent = new JPanel();
|
||||
|
||||
pnContent.add(button);
|
||||
pnContent.add(label);
|
||||
pnContent.add(comboBox);
|
||||
|
||||
frame = new JFrame();
|
||||
|
||||
frame.add(pnContent);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
robot.keyRelease(KeyEvent.VK_L);
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
robot.keyRelease(keys.get(i));
|
||||
}
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
|
||||
int keyMask = InputEvent.ALT_MASK;
|
||||
if (Platform.isOSX()) {
|
||||
keyMask = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
|
||||
}
|
||||
ArrayList<Integer> keys = Util.getKeyCodesFromKeyMask(keyMask);
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
robot.keyPress(keys.get(i));
|
||||
}
|
||||
|
||||
robot.keyPress(KeyEvent.VK_L);
|
||||
|
||||
robot.waitForIdle();
|
||||
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
|
||||
EventQueue.getMostRecentEventTime(), 0, KeyEvent.VK_L, 'L'));
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (!comboBox.isFocusOwner()) {
|
||||
throw new RuntimeException("comboBox isn't focus owner");
|
||||
}
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
robot.keyRelease(KeyEvent.VK_L);
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
robot.keyRelease(keys.get(i));
|
||||
}
|
||||
robot.waitForIdle();
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,48 +40,53 @@ import java.awt.*;
|
||||
public class bug6824395 {
|
||||
|
||||
static JScrollPane scrollPane;
|
||||
static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
JFrame frame = new JFrame("testing");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JEditorPane editorPane = new JEditorPane();
|
||||
String str = "hello\n";
|
||||
for(int i = 0; i<5; i++) {
|
||||
str += str;
|
||||
}
|
||||
|
||||
editorPane.setText(str);
|
||||
|
||||
JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
|
||||
LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
|
||||
editorPaneLayer.setUI(layerUI);
|
||||
|
||||
scrollPane = new JScrollPane(editorPaneLayer);
|
||||
scrollPane.setViewportBorder(null);
|
||||
scrollPane.setPreferredSize(new Dimension(200, 250));
|
||||
frame.add(scrollPane);
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
try {
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.waitForIdle(300);
|
||||
}catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new Error("Unexpected Failure");
|
||||
}
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
|
||||
throw new RuntimeException("Wrong component's width!");
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame("testing");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JEditorPane editorPane = new JEditorPane();
|
||||
String str = "hello\n";
|
||||
for(int i = 0; i<5; i++) {
|
||||
str += str;
|
||||
}
|
||||
|
||||
editorPane.setText(str);
|
||||
|
||||
JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
|
||||
LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
|
||||
editorPaneLayer.setUI(layerUI);
|
||||
|
||||
scrollPane = new JScrollPane(editorPaneLayer);
|
||||
scrollPane.setViewportBorder(null);
|
||||
scrollPane.setPreferredSize(new Dimension(200, 250));
|
||||
frame.add(scrollPane);
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
try {
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.waitForIdle(300);
|
||||
}catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new Error("Unexpected Failure");
|
||||
}
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
|
||||
throw new RuntimeException("Wrong component's width!");
|
||||
}
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,33 +42,38 @@ public class bug6462008 {
|
||||
private static int controlKey;
|
||||
private static JList list;
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
try {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
isAquaLAF = "Aqua".equals(UIManager.getLookAndFeel().getID());
|
||||
controlKey = isAquaLAF ? KeyEvent.VK_META : KeyEvent.VK_CONTROL;
|
||||
isAquaLAF = "Aqua".equals(UIManager.getLookAndFeel().getID());
|
||||
controlKey = isAquaLAF ? KeyEvent.VK_META : KeyEvent.VK_CONTROL;
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.waitForIdle();
|
||||
|
||||
setAnchorLead(-1);
|
||||
robot.waitForIdle();
|
||||
setAnchorLead(-1);
|
||||
robot.waitForIdle();
|
||||
|
||||
testListSelection();
|
||||
testListSelection();
|
||||
|
||||
setAnchorLead(100);
|
||||
robot.waitForIdle();
|
||||
setAnchorLead(100);
|
||||
robot.waitForIdle();
|
||||
|
||||
testListSelection();
|
||||
testListSelection();
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public static void testListSelection() throws Exception {
|
||||
@ -351,7 +356,7 @@ public class bug6462008 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("bug6462008");
|
||||
frame = new JFrame("bug6462008");
|
||||
frame.setSize(200, 500);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
|
||||
@ -35,9 +35,10 @@ import java.awt.event.KeyEvent;
|
||||
|
||||
public class bug6510999 {
|
||||
private static JScrollPane s;
|
||||
static JFrame frame;
|
||||
|
||||
private static void createGui() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
DefaultListModel dlm = new DefaultListModel();
|
||||
@ -57,20 +58,24 @@ public class bug6510999 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bug6510999.createGui();
|
||||
try {
|
||||
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");
|
||||
}
|
||||
});
|
||||
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");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ import java.awt.*;
|
||||
public class bug4417601 {
|
||||
static JMenu menu;
|
||||
static volatile boolean flag;
|
||||
static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@ -47,7 +48,7 @@ public class bug4417601 {
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
menu = new JMenu("Menu");
|
||||
JMenuBar bar = new JMenuBar();
|
||||
@ -75,6 +76,7 @@ public class bug4417601 {
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
if (flag) {
|
||||
throw new RuntimeException("Empty popup was shown");
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ public class bug4515762 {
|
||||
|
||||
private static volatile boolean actionExpected = false;
|
||||
private static volatile boolean actionRecieved = false;
|
||||
private static JFrame frame;
|
||||
|
||||
/**
|
||||
* @param str name of Menu
|
||||
@ -107,65 +108,69 @@ public class bug4515762 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame frame = new JFrame("Test");
|
||||
frame.setJMenuBar(createMenuBar());
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
@Override
|
||||
public void run() {
|
||||
frame = new JFrame("Test");
|
||||
frame.setJMenuBar(createMenuBar());
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_D);
|
||||
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);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.waitForIdle();
|
||||
// Unique menu items.
|
||||
actionExpected = true;
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_D);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_S);
|
||||
robot.keyRelease(KeyEvent.VK_S);
|
||||
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);
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
robot.keyPress(KeyEvent.VK_M);
|
||||
robot.keyRelease(KeyEvent.VK_M);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_T);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_W);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_U);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
robot.waitForIdle();
|
||||
|
||||
// Unique menu items.
|
||||
actionExpected = true;
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
|
||||
robot.keyPress(KeyEvent.VK_S);
|
||||
robot.keyRelease(KeyEvent.VK_S);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
robot.keyPress(KeyEvent.VK_M);
|
||||
robot.keyRelease(KeyEvent.VK_M);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_T);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_W);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_U);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,42 +42,45 @@ public class bug4692443 {
|
||||
public static PassedListener pass;
|
||||
public static FailedListener fail;
|
||||
public static volatile Boolean passed;
|
||||
public static JFrame mainFrame;
|
||||
|
||||
public static void main(String args[]) throws Throwable {
|
||||
try {
|
||||
fail = new FailedListener();
|
||||
pass = new PassedListener();
|
||||
passed = false;
|
||||
Robot robo = new Robot();
|
||||
|
||||
fail = new FailedListener();
|
||||
pass = new PassedListener();
|
||||
passed = false;
|
||||
Robot robo = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
robo.waitForIdle();
|
||||
|
||||
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);
|
||||
|
||||
robo.waitForIdle();
|
||||
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Test failed.");
|
||||
}
|
||||
});
|
||||
|
||||
robo.waitForIdle();
|
||||
|
||||
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);
|
||||
|
||||
robo.waitForIdle();
|
||||
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Test failed.");
|
||||
} finally {
|
||||
if (mainFrame != null) SwingUtilities.invokeAndWait(() -> mainFrame.dispose());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame mainFrame = new JFrame("Bug 4692443");
|
||||
mainFrame = new JFrame("Bug 4692443");
|
||||
JMenuBar mbar = new JMenuBar();
|
||||
JMenu menu = new JMenu("File");
|
||||
menu.setMnemonic('F');
|
||||
|
||||
@ -39,48 +39,52 @@ import java.awt.event.InputEvent;
|
||||
|
||||
public class bug6359669 {
|
||||
static JMenu menu;
|
||||
static JFrame f;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
f = new JFrame();
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menu = new JMenu("Test");
|
||||
menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
}
|
||||
|
||||
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 popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||
}
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
menu.add(new JMenuItem("An item"));
|
||||
}
|
||||
});
|
||||
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
menu.add(new JMenuItem("An item"));
|
||||
}
|
||||
});
|
||||
menuBar.add(menu);
|
||||
f.setJMenuBar(menuBar);
|
||||
|
||||
menuBar.add(menu);
|
||||
f.setJMenuBar(menuBar);
|
||||
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setSize(200, 200);
|
||||
f.setVisible(true);
|
||||
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 ?");
|
||||
}
|
||||
});
|
||||
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 ?");
|
||||
} finally {
|
||||
if (f != null) SwingUtilities.invokeAndWait(() -> f.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,47 +43,51 @@ public class bug6470128 {
|
||||
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);
|
||||
try {
|
||||
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");
|
||||
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.setJMenuBar(bar);
|
||||
bar.add(menu);
|
||||
menu.add(subMenu);
|
||||
subMenu.add(item);
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.waitForIdle();
|
||||
if (Platform.isOSX()) {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
});
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
robot.waitForIdle();
|
||||
if (Platform.isOSX()) {
|
||||
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 (Platform.isOSX()) {
|
||||
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");
|
||||
robot.keyPress(KeyEvent.VK_ALT);
|
||||
robot.keyPress(KeyEvent.VK_M);
|
||||
robot.keyRelease(KeyEvent.VK_M);
|
||||
robot.keyRelease(KeyEvent.VK_ALT);
|
||||
if (Platform.isOSX()) {
|
||||
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");
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ public class bug6538132 {
|
||||
private static JMenu menu1;
|
||||
private static JMenu menu2;
|
||||
private static volatile boolean isWinLaf;
|
||||
private static JFrame frame;
|
||||
|
||||
private static void createGui() {
|
||||
try {
|
||||
@ -53,7 +54,7 @@ public class bug6538132 {
|
||||
isWinLaf = false;
|
||||
return;
|
||||
}
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
@ -76,35 +77,39 @@ public class bug6538132 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
bug6538132.createGui();
|
||||
try {
|
||||
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();
|
||||
}
|
||||
});
|
||||
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();
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,35 +40,39 @@ public class bug4750590 {
|
||||
|
||||
public static PassedListener pass = new PassedListener();
|
||||
public static volatile boolean passed = false;
|
||||
private static JFrame mainFrame;
|
||||
|
||||
public static void main(String args[]) throws Throwable {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
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);
|
||||
|
||||
robo.waitForIdle();
|
||||
|
||||
if (passed) {
|
||||
System.out.println("Test passed!");
|
||||
} else {
|
||||
throw new RuntimeException("Test FAILED!");
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
robo.waitForIdle();
|
||||
|
||||
if (passed) {
|
||||
System.out.println("Test passed!");
|
||||
} else {
|
||||
throw new RuntimeException("Test FAILED!");
|
||||
} finally {
|
||||
if (mainFrame != null) SwingUtilities.invokeAndWait(() -> mainFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame mainFrame = new JFrame("Bug 4750590");
|
||||
mainFrame = new JFrame("Bug 4750590");
|
||||
JMenuBar mbar = new JMenuBar();
|
||||
JMenu menu = new JMenu("File");
|
||||
menu.setMnemonic('F');
|
||||
|
||||
@ -40,26 +40,31 @@ import javax.swing.event.*;
|
||||
public class bug4171437 {
|
||||
static volatile boolean closeActivated = false;
|
||||
static volatile boolean customActivated = false;
|
||||
static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_F);
|
||||
Util.hitKeys(robot, KeyEvent.VK_C);
|
||||
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!closeActivated || customActivated) {
|
||||
throw new RuntimeException("Didn't pass the muster");
|
||||
}
|
||||
});
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.waitForIdle();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_F);
|
||||
Util.hitKeys(robot, KeyEvent.VK_C);
|
||||
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!closeActivated || customActivated) {
|
||||
throw new RuntimeException("Didn't pass the muster");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
public static void createAndShowGUI() {
|
||||
@ -99,7 +104,7 @@ public class bug4171437 {
|
||||
});
|
||||
menubar.add( custom);
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setJMenuBar( menubar);
|
||||
frame.setSize(300, 300);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
@ -42,79 +42,84 @@ public class bug4654927 {
|
||||
|
||||
private static volatile JMenu menu;
|
||||
private static volatile JMenuItem menuItem;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String systemLAF = UIManager.getSystemLookAndFeelClassName();
|
||||
// the test is not applicable to Motif L&F
|
||||
if(systemLAF.endsWith("MotifLookAndFeel")){
|
||||
return;
|
||||
}
|
||||
|
||||
UIManager.setLookAndFeel(systemLAF);
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
createAndShowUI();
|
||||
try {
|
||||
String systemLAF = UIManager.getSystemLookAndFeelClassName();
|
||||
// the test is not applicable to Motif L&F
|
||||
if(systemLAF.endsWith("MotifLookAndFeel")){
|
||||
return;
|
||||
}
|
||||
});
|
||||
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);
|
||||
robot.waitForIdle();
|
||||
UIManager.setLookAndFeel(systemLAF);
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
point = Util.getCenterPoint(menuItem);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
if (!isMenuItemShowing()) {
|
||||
throw new RuntimeException("Popup is unexpectedly closed");
|
||||
}
|
||||
public void run() {
|
||||
createAndShowUI();
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
|
||||
// test mouse drag
|
||||
point = Util.getCenterPoint(menu);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
Point menuLocation = Util.invokeOnEDT(new Callable<Point>() {
|
||||
// test mouse press
|
||||
Point point = Util.getCenterPoint(menu);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
@Override
|
||||
public Point call() throws Exception {
|
||||
return menu.getLocationOnScreen();
|
||||
point = Util.getCenterPoint(menuItem);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!isMenuItemShowing()) {
|
||||
throw new RuntimeException("Popup is unexpectedly closed");
|
||||
}
|
||||
});
|
||||
|
||||
Point itemLocation = Util.invokeOnEDT(new Callable<Point>() {
|
||||
// test mouse drag
|
||||
point = Util.getCenterPoint(menu);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
Point menuLocation = Util.invokeOnEDT(new Callable<Point>() {
|
||||
|
||||
@Override
|
||||
public Point call() throws Exception {
|
||||
return menuItem.getLocationOnScreen();
|
||||
@Override
|
||||
public Point call() throws Exception {
|
||||
return menu.getLocationOnScreen();
|
||||
}
|
||||
});
|
||||
|
||||
Point itemLocation = Util.invokeOnEDT(new Callable<Point>() {
|
||||
|
||||
@Override
|
||||
public Point call() throws Exception {
|
||||
return menuItem.getLocationOnScreen();
|
||||
}
|
||||
});
|
||||
|
||||
int x0 = menuLocation.x + 10;
|
||||
int y0 = menuLocation.y + 10;
|
||||
int x1 = itemLocation.x + 10;
|
||||
int y1 = itemLocation.y + 10;
|
||||
|
||||
// close menu
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
Util.glide(robot, x0, y0, x1, y1);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!isMenuItemShowing()) {
|
||||
throw new RuntimeException("Popup is unexpectedly closed");
|
||||
}
|
||||
});
|
||||
|
||||
int x0 = menuLocation.x + 10;
|
||||
int y0 = menuLocation.y + 10;
|
||||
int x1 = itemLocation.x + 10;
|
||||
int y1 = itemLocation.y + 10;
|
||||
|
||||
// close menu
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
Util.glide(robot, x0, y0, x1, y1);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!isMenuItemShowing()) {
|
||||
throw new RuntimeException("Popup is unexpectedly closed");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +134,7 @@ public class bug4654927 {
|
||||
}
|
||||
|
||||
private static void createAndShowUI() {
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
menu = new JMenu("Menu");
|
||||
|
||||
@ -40,37 +40,41 @@ public class bug6209975 {
|
||||
|
||||
private static JMenu menu;
|
||||
private static JButton button;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
Point clickPoint = getButtonClickPoint();
|
||||
robot.mouseMove(clickPoint.x, clickPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
clickPoint = getMenuClickPoint();
|
||||
robot.mouseMove(clickPoint.x, clickPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (RO1.itsValue <= RO2.itsValue) {
|
||||
throw new RuntimeException("Offset if the second icon is invalid.");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
Point clickPoint = getButtonClickPoint();
|
||||
robot.mouseMove(clickPoint.x, clickPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
clickPoint = getMenuClickPoint();
|
||||
robot.mouseMove(clickPoint.x, clickPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (RO1.itsValue <= RO2.itsValue) {
|
||||
throw new RuntimeException("Offset if the second icon is invalid.");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +109,7 @@ public class bug6209975 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("Test6209975");
|
||||
frame = new JFrame("Test6209975");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
|
||||
frame.setLayout(new BorderLayout());
|
||||
|
||||
@ -40,7 +40,7 @@ public class bug4634626 {
|
||||
public boolean passed = true;
|
||||
public boolean done = false;
|
||||
|
||||
public JFrame mainFrame = new JFrame("Bug4634626");
|
||||
public static JFrame mainFrame = new JFrame("Bug4634626");
|
||||
public JRootPane rootPane = mainFrame.getRootPane();
|
||||
public JPanel contentPane = new JPanel();
|
||||
public JButton nopButton = new JButton("No popup button");
|
||||
@ -83,10 +83,14 @@ public class bug4634626 {
|
||||
|
||||
public static MouseWatcher mouser = new MouseWatcher();
|
||||
|
||||
public static void main(final String[] args) {
|
||||
bug4634626 app = new bug4634626();
|
||||
app.init();
|
||||
app.destroy();
|
||||
public static void main(final String[] args) throws Exception {
|
||||
try {
|
||||
bug4634626 app = new bug4634626();
|
||||
app.init();
|
||||
app.destroy();
|
||||
} finally {
|
||||
if (mainFrame != null) SwingUtilities.invokeAndWait(() -> mainFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
@ -42,9 +42,10 @@ public class bug6217905 {
|
||||
private static JPanel popupPanel;
|
||||
private static JMenuItem firstItem;
|
||||
private static JMenuItem lastItem;
|
||||
private static JFrame frame;
|
||||
|
||||
private static void createGui() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JPopupMenu popup = new JPopupMenu("Menu");
|
||||
@ -70,44 +71,48 @@ public class bug6217905 {
|
||||
return;
|
||||
}
|
||||
|
||||
ExtendedRobot robot = new ExtendedRobot();
|
||||
robot.setAutoDelay(10);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
bug6217905.createGui();
|
||||
try {
|
||||
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.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");
|
||||
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");
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,55 +38,60 @@ import java.awt.*;
|
||||
public class bug6515446 {
|
||||
private static JPanel panel;
|
||||
private static volatile boolean flag;
|
||||
private static JFrame frame;
|
||||
|
||||
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);
|
||||
try {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
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);
|
||||
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());
|
||||
}
|
||||
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);
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
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");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,69 +63,73 @@ public class bug6580930 {
|
||||
|
||||
|
||||
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;
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
JPopupMenu.setDefaultLightWeightPopupEnabled(true);
|
||||
bug6580930.createGui();
|
||||
}
|
||||
});
|
||||
|
||||
Dimension screenSize = toolkit.getScreenSize();
|
||||
frame.setLocation(screenSize.width/2, screenSize.height - frame.getHeight() - insets.bottom + 10);
|
||||
frame.setVisible(true);
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> loc = frame.getLocationOnScreen());
|
||||
robot.waitForIdle();
|
||||
|
||||
if(skipTest) {
|
||||
return;
|
||||
}
|
||||
robot.mouseMove(loc.x, loc.y);
|
||||
showPopup();
|
||||
robot.waitForIdle();
|
||||
if (!System.getProperty("os.name").startsWith("Mac")
|
||||
&& isHeavyWeightMenuVisible()) {
|
||||
throw new RuntimeException("HeavyWeightPopup is unexpectedly visible");
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> loc = frame.getLocationOnScreen());
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
|
||||
robot.mouseMove(loc.x, loc.y);
|
||||
showPopup();
|
||||
robot.waitForIdle();
|
||||
if (!System.getProperty("os.name").startsWith("Mac")
|
||||
&& isHeavyWeightMenuVisible()) {
|
||||
throw new RuntimeException("HeavyWeightPopup is unexpectedly visible");
|
||||
}
|
||||
int x = loc.x;
|
||||
SwingUtilities.invokeAndWait( () -> y = loc.y + (frame.getHeight() -
|
||||
popup.getPreferredSize().height) + 1);
|
||||
robot.waitForIdle();
|
||||
robot.mouseMove(x, y);
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
showPopup();
|
||||
SwingUtilities.invokeAndWait(() -> loc = popup.getLocationOnScreen());
|
||||
robot.waitForIdle();
|
||||
|
||||
int x = loc.x;
|
||||
SwingUtilities.invokeAndWait( () -> y = loc.y + (frame.getHeight() -
|
||||
popup.getPreferredSize().height) + 1);
|
||||
robot.waitForIdle();
|
||||
robot.mouseMove(x, y);
|
||||
if (!loc.equals(new Point(x, y))) {
|
||||
throw new RuntimeException("Popup is unexpectedly shifted");
|
||||
}
|
||||
|
||||
showPopup();
|
||||
SwingUtilities.invokeAndWait(() -> loc = popup.getLocationOnScreen());
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!loc.equals(new Point(x, y))) {
|
||||
throw new RuntimeException("Popup is unexpectedly shifted");
|
||||
}
|
||||
|
||||
if (!isHeavyWeightMenuVisible()) {
|
||||
throw new RuntimeException("HeavyWeightPopup is unexpectedly hidden");
|
||||
if (!isHeavyWeightMenuVisible()) {
|
||||
throw new RuntimeException("HeavyWeightPopup is unexpectedly hidden");
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,56 +44,60 @@ public class bug6827786 {
|
||||
|
||||
private static JMenu menu;
|
||||
private static Component focusable;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
// move mouse outside menu to prevent auto selection
|
||||
robot.mouseMove(100,100);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
// move mouse outside menu to prevent auto selection
|
||||
robot.mouseMove(100,100);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
focusable.requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
checkfocus();
|
||||
|
||||
// select menu
|
||||
if (Platform.isOSX()) {
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
|
||||
} else {
|
||||
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
|
||||
}
|
||||
});
|
||||
// select submenu
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
robot.waitForIdle();
|
||||
// verify submenu is selected
|
||||
verify(1);
|
||||
|
||||
robot.waitForIdle();
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
robot.waitForIdle();
|
||||
// verify last item is selected
|
||||
verify(2);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
robot.waitForIdle();
|
||||
// selection should wrap to first item
|
||||
verify(0);
|
||||
|
||||
public void run() {
|
||||
focusable.requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
checkfocus();
|
||||
|
||||
// select menu
|
||||
if (Platform.isOSX()) {
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
|
||||
} else {
|
||||
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
|
||||
System.out.println("PASSED");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
// select submenu
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
robot.waitForIdle();
|
||||
// verify submenu is selected
|
||||
verify(1);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
robot.waitForIdle();
|
||||
// verify last item is selected
|
||||
verify(2);
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_S);
|
||||
robot.waitForIdle();
|
||||
// selection should wrap to first item
|
||||
verify(0);
|
||||
|
||||
System.out.println("PASSED");
|
||||
|
||||
}
|
||||
|
||||
private static void checkfocus() throws Exception {
|
||||
@ -144,7 +148,7 @@ public class bug6827786 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("bug6827786");
|
||||
frame = new JFrame("bug6827786");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setJMenuBar(createMenuBar());
|
||||
focusable = new JButton("Set Focus Here");
|
||||
|
||||
@ -37,56 +37,61 @@ import java.awt.event.InputEvent;
|
||||
public class bug6987844 {
|
||||
static JMenu menu1;
|
||||
static JMenu menu2;
|
||||
static JFrame frame;
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(200);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(200);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JMenuBar bar = new JMenuBar();
|
||||
menu1 = new JMenu("Menu1");
|
||||
menu1.add(new JMenuItem("item"));
|
||||
bar.add(menu1);
|
||||
menu2 = new JMenu("Menu2");
|
||||
menu2.add(new JMenuItem("item"));
|
||||
menu2.add(new JMenuItem("item"));
|
||||
bar.add(menu2);
|
||||
JMenuBar bar = new JMenuBar();
|
||||
menu1 = new JMenu("Menu1");
|
||||
menu1.add(new JMenuItem("item"));
|
||||
bar.add(menu1);
|
||||
menu2 = new JMenu("Menu2");
|
||||
menu2.add(new JMenuItem("item"));
|
||||
menu2.add(new JMenuItem("item"));
|
||||
bar.add(menu2);
|
||||
|
||||
frame.setJMenuBar(bar);
|
||||
frame.pack();
|
||||
frame.setJMenuBar(bar);
|
||||
frame.pack();
|
||||
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point point1 = menu1.getLocationOnScreen();
|
||||
Point point2 = menu2.getLocationOnScreen();
|
||||
|
||||
robot.mouseMove(point1.x + 1, point1.y + 1);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.mouseMove(point2.x + 1, point2.y + 1);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.mouseMove(point1.x + 1, point1.y + 1);
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Dimension popupSize1 = menu1.getPopupMenu().getSize();
|
||||
Dimension popupSize2 = menu2.getPopupMenu().getSize();
|
||||
if (popupSize1.equals(popupSize2)) {
|
||||
throw new RuntimeException("First popup unexpedetly changed its size");
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point point1 = menu1.getLocationOnScreen();
|
||||
Point point2 = menu2.getLocationOnScreen();
|
||||
|
||||
robot.mouseMove(point1.x + 1, point1.y + 1);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.mouseMove(point2.x + 1, point2.y + 1);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.mouseMove(point1.x + 1, point1.y + 1);
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Dimension popupSize1 = menu1.getPopupMenu().getSize();
|
||||
Dimension popupSize2 = menu2.getPopupMenu().getSize();
|
||||
if (popupSize1.equals(popupSize2)) {
|
||||
throw new RuntimeException("First popup unexpedetly changed its size");
|
||||
}
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,49 +45,53 @@ import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
public class bug8041561 {
|
||||
|
||||
private static JRadioButton radioButton;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
|
||||
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||
createAndShowGUI();
|
||||
} catch (UnsupportedLookAndFeelException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
new Robot().waitForIdle();
|
||||
Thread.sleep(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Point point = radioButton.getLocationOnScreen();
|
||||
int x = (int) point.getX() + radioButton.getWidth() / 2;
|
||||
int y = (int) point.getY() + radioButton.getHeight() / 2;
|
||||
|
||||
Robot robot = new Robot();
|
||||
Color color = robot.getPixelColor(x, y);
|
||||
if (!Color.BLUE.equals(color)) {
|
||||
throw new RuntimeException("JRadioButton is opaque");
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
|
||||
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||
createAndShowGUI();
|
||||
} catch (UnsupportedLookAndFeelException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (AWTException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
new Robot().waitForIdle();
|
||||
Thread.sleep(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Point point = radioButton.getLocationOnScreen();
|
||||
int x = (int) point.getX() + radioButton.getWidth() / 2;
|
||||
int y = (int) point.getY() + radioButton.getHeight() / 2;
|
||||
|
||||
Robot robot = new Robot();
|
||||
Color color = robot.getPixelColor(x, y);
|
||||
if (!Color.BLUE.equals(color)) {
|
||||
throw new RuntimeException("JRadioButton is opaque");
|
||||
}
|
||||
} catch (AWTException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setBackground(Color.BLUE);
|
||||
radioButton = new JRadioButton();
|
||||
|
||||
@ -40,25 +40,30 @@ import java.awt.*;
|
||||
public class bug8075609 {
|
||||
private static Robot robot;
|
||||
private static JTextField textField;
|
||||
private static JFrame mainFrame;
|
||||
|
||||
public static void main(String args[]) throws Throwable {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot = new Robot();
|
||||
Thread.sleep(100);
|
||||
robot = new Robot();
|
||||
Thread.sleep(100);
|
||||
|
||||
robot.setAutoDelay(100);
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
// Radio button group tab key test
|
||||
runTest1();
|
||||
// Radio button group tab key test
|
||||
runTest1();
|
||||
} finally {
|
||||
if (mainFrame != null) SwingUtilities.invokeAndWait(() -> mainFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame mainFrame = new JFrame("Bug 8075609 - 1 test");
|
||||
mainFrame = new JFrame("Bug 8075609 - 1 test");
|
||||
|
||||
JPanel rootPanel = new JPanel();
|
||||
rootPanel.setLayout(new BorderLayout());
|
||||
|
||||
@ -39,6 +39,7 @@ public class bug4670486 {
|
||||
|
||||
public static volatile boolean actionExpected = false;
|
||||
public static volatile boolean actionRecieved = false;
|
||||
public static JFrame frame;
|
||||
|
||||
private static JMenuBar createMenuBar() {
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
@ -101,44 +102,48 @@ public class bug4670486 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame frame = new JFrame("Test");
|
||||
frame.setContentPane(createPanel(frame));
|
||||
frame.setJMenuBar(createMenuBar());
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run() {
|
||||
frame = new JFrame("Test");
|
||||
frame.setContentPane(createPanel(frame));
|
||||
frame.setJMenuBar(createMenuBar());
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.waitForIdle();
|
||||
|
||||
// Change the default button to
|
||||
// force a call to BasicRootPaneUI.updateDefaultButtonBindings()
|
||||
Util.hitKeys(robot, KeyEvent.VK_TAB);
|
||||
// Change the default button to
|
||||
// force a call to BasicRootPaneUI.updateDefaultButtonBindings()
|
||||
Util.hitKeys(robot, KeyEvent.VK_TAB);
|
||||
|
||||
// If the bug exists, then as soon as the menu appears,
|
||||
// the VK_ENTER, VK_DOWN, VK_UP and VK_ESC will have no
|
||||
// effect.
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
// If the bug exists, then as soon as the menu appears,
|
||||
// the VK_ENTER, VK_DOWN, VK_UP and VK_ESC will have no
|
||||
// effect.
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
checkAction();
|
||||
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
Util.hitMnemonics(robot, KeyEvent.VK_U);
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
|
||||
checkAction();
|
||||
checkAction();
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,62 +40,67 @@ public class bug4708809 {
|
||||
private static volatile boolean passed = true;
|
||||
private static JScrollPane spane;
|
||||
private static JScrollBar sbar;
|
||||
private static JFrame fr;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(350);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(350);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
spane.requestFocus();
|
||||
sbar.setValue(sbar.getMaximum());
|
||||
}
|
||||
});
|
||||
public void run() {
|
||||
spane.requestFocus();
|
||||
sbar.setValue(sbar.getMaximum());
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.waitForIdle();
|
||||
|
||||
Point point = getClickPoint(0.5, 0.5);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
Point point = getClickPoint(0.5, 0.5);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
final int oldValue = sbar.getValue();
|
||||
sbar.addAdjustmentListener(new AdjustmentListener() {
|
||||
public void run() {
|
||||
final int oldValue = sbar.getValue();
|
||||
sbar.addAdjustmentListener(new AdjustmentListener() {
|
||||
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
if (e.getValue() >= oldValue) {
|
||||
passed = false;
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
if (e.getValue() >= oldValue) {
|
||||
passed = false;
|
||||
}
|
||||
do_test = true;
|
||||
}
|
||||
do_test = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
point = getClickPoint(0.5, 0.2);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!do_test || !passed) {
|
||||
throw new Exception("The scrollbar moved with incorrect direction");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
point = getClickPoint(0.5, 0.2);
|
||||
robot.mouseMove(point.x, point.y);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!do_test || !passed) {
|
||||
throw new Exception("The scrollbar moved with incorrect direction");
|
||||
} finally {
|
||||
if (fr != null) SwingUtilities.invokeAndWait(() -> fr.dispose());
|
||||
}
|
||||
|
||||
}
|
||||
@ -119,7 +124,7 @@ public class bug4708809 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame fr = new JFrame("Test");
|
||||
fr = new JFrame("Test");
|
||||
|
||||
JLabel label = new JLabel("picture");
|
||||
label.setPreferredSize(new Dimension(500, 500));
|
||||
|
||||
@ -38,33 +38,37 @@ import java.util.*;
|
||||
public class bug4865918 {
|
||||
|
||||
private static TestScrollBar sbar;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
Robot robot = new Robot();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sbar.pressMouse();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
int value = getValue();
|
||||
|
||||
if (value != 9) {
|
||||
throw new Error("The scrollbar block increment is incorect");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sbar.pressMouse();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
int value = getValue();
|
||||
|
||||
if (value != 9) {
|
||||
throw new Error("The scrollbar block increment is incorect");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +86,7 @@ public class bug4865918 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("bug4865918");
|
||||
frame = new JFrame("bug4865918");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
sbar = new TestScrollBar(JScrollBar.HORIZONTAL, -1, 10, -100, 100);
|
||||
|
||||
@ -38,64 +38,69 @@ import java.awt.event.InputEvent;
|
||||
public class bug6542335 {
|
||||
private static JScrollBar sb;
|
||||
private static MyScrollBarUI ui;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
try {
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(10);
|
||||
|
||||
final Rectangle[] thumbBounds = new Rectangle[1];
|
||||
final Rectangle[] thumbBounds = new Rectangle[1];
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
final JFrame frame = new JFrame("bug6542335");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame("bug6542335");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
sb = new JScrollBar(0, 0, 1, 0, 1);
|
||||
sb = new JScrollBar(0, 0, 1, 0, 1);
|
||||
|
||||
ui = new MyScrollBarUI();
|
||||
sb.setUI(ui);
|
||||
ui = new MyScrollBarUI();
|
||||
sb.setUI(ui);
|
||||
|
||||
sb.setPreferredSize(new Dimension(200, 17));
|
||||
DefaultBoundedRangeModel rangeModel = new DefaultBoundedRangeModel();
|
||||
rangeModel.setMaximum(100);
|
||||
rangeModel.setMinimum(0);
|
||||
rangeModel.setExtent(50);
|
||||
rangeModel.setValue(50);
|
||||
sb.setPreferredSize(new Dimension(200, 17));
|
||||
DefaultBoundedRangeModel rangeModel = new DefaultBoundedRangeModel();
|
||||
rangeModel.setMaximum(100);
|
||||
rangeModel.setMinimum(0);
|
||||
rangeModel.setExtent(50);
|
||||
rangeModel.setValue(50);
|
||||
|
||||
sb.setModel(rangeModel);
|
||||
frame.add(sb, BorderLayout.NORTH);
|
||||
sb.setModel(rangeModel);
|
||||
frame.add(sb, BorderLayout.NORTH);
|
||||
|
||||
frame.setSize(200, 100);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
thumbBounds[0] = new Rectangle(ui.getThumbBounds());
|
||||
|
||||
Point l = sb.getLocationOnScreen();
|
||||
|
||||
robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Rectangle newThumbBounds = ui.getThumbBounds();
|
||||
|
||||
if (!thumbBounds[0].equals(newThumbBounds)) {
|
||||
throw new RuntimeException("Test failed.\nOld bounds: " + thumbBounds[0] +
|
||||
"\nNew bounds: " + newThumbBounds);
|
||||
frame.setSize(200, 100);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
thumbBounds[0] = new Rectangle(ui.getThumbBounds());
|
||||
|
||||
Point l = sb.getLocationOnScreen();
|
||||
|
||||
robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Rectangle newThumbBounds = ui.getThumbBounds();
|
||||
|
||||
if (!thumbBounds[0].equals(newThumbBounds)) {
|
||||
throw new RuntimeException("Test failed.\nOld bounds: " + thumbBounds[0] +
|
||||
"\nNew bounds: " + newThumbBounds);
|
||||
}
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
static class MyScrollBarUI extends BasicScrollBarUI {
|
||||
|
||||
@ -40,50 +40,55 @@ import jdk.test.lib.Platform;
|
||||
public class bug4202954 {
|
||||
static JScrollPane buttonScrollPane;
|
||||
static Robot robot;
|
||||
static JFrame testFrame;
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (Platform.isOSX()) {
|
||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
try {
|
||||
if (Platform.isOSX()) {
|
||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
}
|
||||
});
|
||||
Point centerOfScrollPane = Util.getCenterPoint(buttonScrollPane);
|
||||
JButton rightScrollButton = findJButton(buttonScrollPane.getHorizontalScrollBar(), centerOfScrollPane.x, centerOfScrollPane.y);
|
||||
JButton bottomScrollButton = findJButton(buttonScrollPane.getVerticalScrollBar(), centerOfScrollPane.x, centerOfScrollPane.y);
|
||||
|
||||
if (rightScrollButton == null || bottomScrollButton == null) {
|
||||
String errMessage = "Test can't be executed: ";
|
||||
errMessage = errMessage + (rightScrollButton == null ? "can't find right button for horizontal scroll bar; " : ""
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
Point centerOfScrollPane = Util.getCenterPoint(buttonScrollPane);
|
||||
JButton rightScrollButton = findJButton(buttonScrollPane.getHorizontalScrollBar(), centerOfScrollPane.x, centerOfScrollPane.y);
|
||||
JButton bottomScrollButton = findJButton(buttonScrollPane.getVerticalScrollBar(), centerOfScrollPane.x, centerOfScrollPane.y);
|
||||
|
||||
if (rightScrollButton == null || bottomScrollButton == null) {
|
||||
String errMessage = "Test can't be executed: ";
|
||||
errMessage = errMessage + (rightScrollButton == null ? "can't find right button for horizontal scroll bar; " : ""
|
||||
+ (bottomScrollButton == null ? "can't find bottom scroll button for vertical scroll bar" : ""));
|
||||
throw new RuntimeException(errMessage);
|
||||
}
|
||||
throw new RuntimeException(errMessage);
|
||||
}
|
||||
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
// test right, left and middle mouse buttons for horizontal scroll bar
|
||||
if (!doTest(rightScrollButton, InputEvent.BUTTON1_DOWN_MASK, true)) {
|
||||
throw new RuntimeException("Test failed: right arrow button didn't respond on left mouse button.");
|
||||
}
|
||||
if (!doTest(rightScrollButton, InputEvent.BUTTON2_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: right arrow button respond on right mouse button.");
|
||||
}
|
||||
if (!doTest(rightScrollButton, InputEvent.BUTTON3_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: right arrow button respond on middle mouse button.");
|
||||
}
|
||||
// test right, left and middle mouse buttons for horizontal scroll bar
|
||||
if (!doTest(rightScrollButton, InputEvent.BUTTON1_DOWN_MASK, true)) {
|
||||
throw new RuntimeException("Test failed: right arrow button didn't respond on left mouse button.");
|
||||
}
|
||||
if (!doTest(rightScrollButton, InputEvent.BUTTON2_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: right arrow button respond on right mouse button.");
|
||||
}
|
||||
if (!doTest(rightScrollButton, InputEvent.BUTTON3_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: right arrow button respond on middle mouse button.");
|
||||
}
|
||||
|
||||
// test right, left and middle mouse buttons for vertical scroll bar
|
||||
if (!doTest(bottomScrollButton, InputEvent.BUTTON1_DOWN_MASK, true)) {
|
||||
throw new RuntimeException("Test failed: bottom arrow button didn't respond on left mouse button.");
|
||||
}
|
||||
if (!doTest(bottomScrollButton, InputEvent.BUTTON2_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: bottom arrow button respond on right mouse button.");
|
||||
}
|
||||
if (!doTest(bottomScrollButton, InputEvent.BUTTON3_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: bottom arrow button respond on middle mouse button.");
|
||||
// test right, left and middle mouse buttons for vertical scroll bar
|
||||
if (!doTest(bottomScrollButton, InputEvent.BUTTON1_DOWN_MASK, true)) {
|
||||
throw new RuntimeException("Test failed: bottom arrow button didn't respond on left mouse button.");
|
||||
}
|
||||
if (!doTest(bottomScrollButton, InputEvent.BUTTON2_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: bottom arrow button respond on right mouse button.");
|
||||
}
|
||||
if (!doTest(bottomScrollButton, InputEvent.BUTTON3_DOWN_MASK, false)) {
|
||||
throw new RuntimeException("Test failed: bottom arrow button respond on middle mouse button.");
|
||||
}
|
||||
} finally {
|
||||
if (testFrame != null) SwingUtilities.invokeAndWait(() -> testFrame.dispose());
|
||||
}
|
||||
}
|
||||
public static void createAndShowGUI() {
|
||||
@ -97,7 +102,7 @@ public class bug4202954 {
|
||||
buttonScrollPane = new JScrollPane();
|
||||
buttonScrollPane.setViewportView(buttonPanel);
|
||||
|
||||
JFrame testFrame = new JFrame("bug4202954");
|
||||
testFrame = new JFrame("bug4202954");
|
||||
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
testFrame.setLayout(new BorderLayout());
|
||||
testFrame.add(BorderLayout.CENTER, buttonScrollPane);
|
||||
|
||||
@ -44,6 +44,7 @@ public class bug4973721 implements ChangeListener, FocusListener {
|
||||
static volatile boolean bFocusGained = false;
|
||||
static JSpinner spinner;
|
||||
static final Object listener = new bug4973721();
|
||||
static JFrame frame;
|
||||
|
||||
public void focusLost(FocusEvent e) {}
|
||||
|
||||
@ -62,58 +63,62 @@ public class bug4973721 implements ChangeListener, FocusListener {
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.setLookAndFeel("javax.swing.plaf.synth.SynthLookAndFeel");
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
final JFrame frame = new JFrame();
|
||||
spinner = new JSpinner();
|
||||
frame.getContentPane().add(spinner);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame();
|
||||
spinner = new JSpinner();
|
||||
frame.getContentPane().add(spinner);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
spinner.addChangeListener((ChangeListener)listener);
|
||||
spinner.addFocusListener((FocusListener)listener);
|
||||
spinner.requestFocus();
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
spinner.addChangeListener((ChangeListener)listener);
|
||||
spinner.addFocusListener((FocusListener)listener);
|
||||
spinner.requestFocus();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
synchronized(listener) {
|
||||
if (!bFocusGained) {
|
||||
System.out.println("waiting focusGained...");
|
||||
try { listener.wait(5000); } catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
synchronized(listener) {
|
||||
if (!bFocusGained) {
|
||||
System.out.println("waiting focusGained...");
|
||||
try { listener.wait(5000); } catch (InterruptedException e) {}
|
||||
boolean hasFocus = Util.invokeOnEDT(new java.util.concurrent.Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
return spinner.hasFocus();
|
||||
}
|
||||
});
|
||||
|
||||
if (!bFocusGained && !hasFocus) {
|
||||
throw new RuntimeException("Couldn't request focus for spinner");
|
||||
}
|
||||
}
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
boolean hasFocus = Util.invokeOnEDT(new java.util.concurrent.Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
return spinner.hasFocus();
|
||||
Util.hitKeys(robot, KeyEvent.VK_UP);
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!bStateChanged) {
|
||||
throw new RuntimeException("Up arrow key button doesn't work for a spinner in Synth L&F");
|
||||
}
|
||||
});
|
||||
|
||||
if (!bFocusGained && !hasFocus) {
|
||||
throw new RuntimeException("Couldn't request focus for spinner");
|
||||
}
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
bStateChanged = false;
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_UP);
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!bStateChanged) {
|
||||
throw new RuntimeException("Up arrow key button doesn't work for a spinner in Synth L&F");
|
||||
}
|
||||
|
||||
bStateChanged = false;
|
||||
|
||||
Util.hitKeys(robot, KeyEvent.VK_DOWN);
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (!bStateChanged) {
|
||||
throw new RuntimeException("Down arrow key button doesn't work for a spinner in Synth L&F");
|
||||
if (!bStateChanged) {
|
||||
throw new RuntimeException("Down arrow key button doesn't work for a spinner in Synth L&F");
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@ public class bug4885629 {
|
||||
private static final Color BGCOLOR = Color.blue;
|
||||
|
||||
private static JSplitPane sp;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.setLookAndFeel(new BasicLookAndFeel() {
|
||||
@ -56,58 +57,62 @@ public class bug4885629 {
|
||||
public String getName() { return "FooName"; }
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
JFrame frame = new JFrame();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame = new JFrame();
|
||||
|
||||
JComponent a = new JPanel();
|
||||
a.setBackground(Color.white);
|
||||
a.setMinimumSize(new Dimension(10, 10));
|
||||
JComponent a = new JPanel();
|
||||
a.setBackground(Color.white);
|
||||
a.setMinimumSize(new Dimension(10, 10));
|
||||
|
||||
JComponent b = new JPanel();
|
||||
b.setBackground(Color.white);
|
||||
b.setMinimumSize(new Dimension(10, 10));
|
||||
JComponent b = new JPanel();
|
||||
b.setBackground(Color.white);
|
||||
b.setMinimumSize(new Dimension(10, 10));
|
||||
|
||||
sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, a, b);
|
||||
sp.setPreferredSize(new Dimension(20, 20));
|
||||
sp.setBackground(BGCOLOR);
|
||||
sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, a, b);
|
||||
sp.setPreferredSize(new Dimension(20, 20));
|
||||
sp.setBackground(BGCOLOR);
|
||||
|
||||
Border bo = new BasicBorders.SplitPaneBorder(lightHighlight,
|
||||
Color.red);
|
||||
Border ibo = new EmptyBorder(0, 0, 0, 0);
|
||||
sp.setBorder(bo);
|
||||
sp.setMinimumSize(new Dimension(200, 200));
|
||||
Border bo = new BasicBorders.SplitPaneBorder(lightHighlight,
|
||||
Color.red);
|
||||
Border ibo = new EmptyBorder(0, 0, 0, 0);
|
||||
sp.setBorder(bo);
|
||||
sp.setMinimumSize(new Dimension(200, 200));
|
||||
|
||||
((BasicSplitPaneUI) sp.getUI()).getDivider().setBorder(ibo);
|
||||
((BasicSplitPaneUI) sp.getUI()).getDivider().setBorder(ibo);
|
||||
|
||||
frame.getContentPane().setLayout(new FlowLayout());
|
||||
frame.getContentPane().setBackground(darkShadow);
|
||||
frame.getContentPane().add(sp);
|
||||
frame.getContentPane().setLayout(new FlowLayout());
|
||||
frame.getContentPane().setBackground(darkShadow);
|
||||
frame.getContentPane().add(sp);
|
||||
|
||||
frame.setSize(200, 200);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
frame.setSize(200, 200);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
final Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
final Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Rectangle rect = ((BasicSplitPaneUI) sp.getUI()).getDivider().getBounds();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Rectangle rect = ((BasicSplitPaneUI) sp.getUI()).getDivider().getBounds();
|
||||
|
||||
Point p = rect.getLocation();
|
||||
Point p = rect.getLocation();
|
||||
|
||||
SwingUtilities.convertPointToScreen(p, sp);
|
||||
SwingUtilities.convertPointToScreen(p, sp);
|
||||
|
||||
for (int i = 0; i < rect.width; i++) {
|
||||
if (!BGCOLOR.equals(robot.getPixelColor(p.x + i, p.y + rect.height - 1))) {
|
||||
throw new Error("The divider's area has incorrect color.");
|
||||
for (int i = 0; i < rect.width; i++) {
|
||||
if (!BGCOLOR.equals(robot.getPixelColor(p.x + i, p.y + rect.height - 1))) {
|
||||
throw new Error("The divider's area has incorrect color.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,44 +39,49 @@ public class bug4361477 {
|
||||
static JTabbedPane tabbedPane;
|
||||
volatile static boolean bStateChanged = false;
|
||||
volatile static Rectangle bounds;
|
||||
static JFrame frame;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
try {
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowUI();
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
bounds = tabbedPane.getUI().getTabBounds(tabbedPane, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Point location = bounds.getLocation();
|
||||
SwingUtilities.convertPointToScreen(location, tabbedPane);
|
||||
robot.mouseMove(location.x + 1, location.y + 1);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
if (!bStateChanged) {
|
||||
throw new RuntimeException("Tabbed pane state is not changed");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
bounds = tabbedPane.getUI().getTabBounds(tabbedPane, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Point location = bounds.getLocation();
|
||||
SwingUtilities.convertPointToScreen(location, tabbedPane);
|
||||
robot.mouseMove(location.x + 1, location.y + 1);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
|
||||
if (!bStateChanged) {
|
||||
throw new RuntimeException("Tabbed pane state is not changed");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
static void createAndShowUI() {
|
||||
|
||||
final JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
tabbedPane = new JTabbedPane();
|
||||
tabbedPane.add("Tab0", new JPanel());
|
||||
tabbedPane.add("Tab1", new JPanel());
|
||||
|
||||
@ -49,6 +49,7 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
private static JTextField txtField;
|
||||
private static JTabbedPane tab;
|
||||
private static Object listener;
|
||||
private static JFrame frame;
|
||||
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
System.out.println("stateChanged called");
|
||||
@ -66,51 +67,55 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
txtField.requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!focusGained) {
|
||||
throw new RuntimeException("Couldn't gain focus for text field");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
tab.addChangeListener((ChangeListener) listener);
|
||||
txtField.removeFocusListener((FocusListener) listener);
|
||||
}
|
||||
});
|
||||
|
||||
public void run() {
|
||||
txtField.requestFocus();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (Platform.isOSX()) {
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
|
||||
} else {
|
||||
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!focusGained) {
|
||||
throw new RuntimeException("Couldn't gain focus for text field");
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
tab.addChangeListener((ChangeListener) listener);
|
||||
txtField.removeFocusListener((FocusListener) listener);
|
||||
if (!stateChanged || tab.getSelectedIndex() != 1) {
|
||||
throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
if (Platform.isOSX()) {
|
||||
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
|
||||
} else {
|
||||
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
|
||||
}
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
if (!stateChanged || tab.getSelectedIndex() != 1) {
|
||||
throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +126,7 @@ public class bug4624207 implements ChangeListener, FocusListener {
|
||||
tab.setMnemonicAt(0, KeyEvent.VK_T);
|
||||
tab.setMnemonicAt(1, KeyEvent.VK_B);
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.getContentPane().add(tab, BorderLayout.CENTER);
|
||||
txtField = new JTextField();
|
||||
frame.getContentPane().add(txtField, BorderLayout.NORTH);
|
||||
|
||||
@ -35,46 +35,51 @@ import java.awt.*;
|
||||
public class bug6495408 {
|
||||
|
||||
static JTabbedPane tabbedPane;
|
||||
static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
try {
|
||||
final Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
final JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
tabbedPane = new JTabbedPane();
|
||||
tabbedPane.setTabPlacement(JTabbedPane.LEFT);
|
||||
tabbedPane.addTab("Hello", null);
|
||||
frame.add(tabbedPane);
|
||||
frame.setSize(400, 400);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
final Rectangle d = new Rectangle();
|
||||
final Point p = new Point();
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
int tab = tabbedPane.getTabCount() - 1;
|
||||
Rectangle bounds = tabbedPane.getBoundsAt(tab);
|
||||
if (bounds != null) {
|
||||
d.setBounds(bounds);
|
||||
p.setLocation(d.x + d.width / 2, d.y + d.height / 2);
|
||||
SwingUtilities.convertPointToScreen(p, tabbedPane);
|
||||
robot.mouseMove(p.x, p.y + d.height);
|
||||
tabbedPane.addTab("Hello", null);
|
||||
}
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
tabbedPane = new JTabbedPane();
|
||||
tabbedPane.setTabPlacement(JTabbedPane.LEFT);
|
||||
tabbedPane.addTab("Hello", null);
|
||||
frame.add(tabbedPane);
|
||||
frame.setSize(400, 400);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
final Rectangle d = new Rectangle();
|
||||
final Point p = new Point();
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
int tab = tabbedPane.getTabCount() - 1;
|
||||
Rectangle bounds = tabbedPane.getBoundsAt(tab);
|
||||
if (bounds != null) {
|
||||
d.setBounds(bounds);
|
||||
p.setLocation(d.x + d.width / 2, d.y + d.height / 2);
|
||||
SwingUtilities.convertPointToScreen(p, tabbedPane);
|
||||
robot.mouseMove(p.x, p.y + d.height);
|
||||
tabbedPane.addTab("Hello", null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,42 +36,47 @@ public class bug7161568 {
|
||||
|
||||
private static final int N = 50;
|
||||
private static JTabbedPane tabbedPane;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.put("TabbedPane.selectionFollowsFocus", Boolean.FALSE);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowUI();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run() {
|
||||
createAndShowUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
tabbedPane.requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
tabbedPane.requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
static void createAndShowUI() {
|
||||
JFrame frame = new JFrame("Test");
|
||||
frame = new JFrame("Test");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(100, 100);
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
||||
public class Bug8134116 {
|
||||
|
||||
private static volatile Exception exception = null;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
@ -29,139 +30,143 @@ public class Bug8134116 {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
JPanel panel0 = new JPanel();
|
||||
JPanel panel2 = new JPanel();
|
||||
BadPane badPane = new BadPane();
|
||||
badPane.add("zero", panel0);
|
||||
badPane.add("one", null); // no component
|
||||
badPane.add("", panel2); // no title
|
||||
badPane.add("", null); // no component, no title
|
||||
// but give it that via a tabComponent
|
||||
JPanel tabComponent = new JPanel();
|
||||
JLabel tabComponentLabel = new JLabel("three");
|
||||
tabComponent.add(tabComponentLabel);
|
||||
badPane.setTabComponentAt(3, tabComponent);
|
||||
JFrame frame = new JFrame();
|
||||
frame.add(badPane);
|
||||
frame.setSize(300, 300);
|
||||
frame.setVisible(true);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
JPanel panel0 = new JPanel();
|
||||
JPanel panel2 = new JPanel();
|
||||
BadPane badPane = new BadPane();
|
||||
badPane.add("zero", panel0);
|
||||
badPane.add("one", null); // no component
|
||||
badPane.add("", panel2); // no title
|
||||
badPane.add("", null); // no component, no title
|
||||
// but give it that via a tabComponent
|
||||
JPanel tabComponent = new JPanel();
|
||||
JLabel tabComponentLabel = new JLabel("three");
|
||||
tabComponent.add(tabComponentLabel);
|
||||
badPane.setTabComponentAt(3, tabComponent);
|
||||
frame = new JFrame();
|
||||
frame.add(badPane);
|
||||
frame.setSize(300, 300);
|
||||
frame.setVisible(true);
|
||||
|
||||
try {
|
||||
AccessibleContext ac = badPane.getAccessibleContext();
|
||||
Accessible page0 = ac.getAccessibleChild(0);
|
||||
if (page0 == null) {
|
||||
// Not something being tested, but checking anyway
|
||||
throw new RuntimeException("getAccessibleChild(0) is null");
|
||||
}
|
||||
Accessible page1 = ac.getAccessibleChild(1);
|
||||
if (page1 == null) {
|
||||
// Not something being tested, but checking anyway
|
||||
throw new RuntimeException("getAccessibleChild(1) is null");
|
||||
}
|
||||
Accessible page2 = ac.getAccessibleChild(2);
|
||||
Accessible page3 = ac.getAccessibleChild(3);
|
||||
// page0 - page3 are JTabbedPane.Page, a private inner class
|
||||
// and is an AccessibleContext
|
||||
// and implements Accessible and AccessibleComponent
|
||||
AccessibleContext pac0 = page0.getAccessibleContext();
|
||||
AccessibleContext pac1 = page1.getAccessibleContext();
|
||||
AccessibleContext pac2 = page2.getAccessibleContext();
|
||||
AccessibleContext pac3 = page3.getAccessibleContext();
|
||||
try {
|
||||
AccessibleContext ac = badPane.getAccessibleContext();
|
||||
Accessible page0 = ac.getAccessibleChild(0);
|
||||
if (page0 == null) {
|
||||
// Not something being tested, but checking anyway
|
||||
throw new RuntimeException("getAccessibleChild(0) is null");
|
||||
}
|
||||
Accessible page1 = ac.getAccessibleChild(1);
|
||||
if (page1 == null) {
|
||||
// Not something being tested, but checking anyway
|
||||
throw new RuntimeException("getAccessibleChild(1) is null");
|
||||
}
|
||||
Accessible page2 = ac.getAccessibleChild(2);
|
||||
Accessible page3 = ac.getAccessibleChild(3);
|
||||
// page0 - page3 are JTabbedPane.Page, a private inner class
|
||||
// and is an AccessibleContext
|
||||
// and implements Accessible and AccessibleComponent
|
||||
AccessibleContext pac0 = page0.getAccessibleContext();
|
||||
AccessibleContext pac1 = page1.getAccessibleContext();
|
||||
AccessibleContext pac2 = page2.getAccessibleContext();
|
||||
AccessibleContext pac3 = page3.getAccessibleContext();
|
||||
|
||||
// test Page.getBounds
|
||||
// ensure no IndexOutOfBoundsException
|
||||
Rectangle r0 = pac0.getAccessibleComponent().getBounds();
|
||||
// make sure second Bounds is different than first
|
||||
Rectangle r1 = pac1.getAccessibleComponent().getBounds();
|
||||
if (r1.equals(r0)) {
|
||||
String msg = "Second tab should not have same bounds as first tab";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// test Page.getBounds
|
||||
// ensure no IndexOutOfBoundsException
|
||||
Rectangle r0 = pac0.getAccessibleComponent().getBounds();
|
||||
// make sure second Bounds is different than first
|
||||
Rectangle r1 = pac1.getAccessibleComponent().getBounds();
|
||||
if (r1.equals(r0)) {
|
||||
String msg = "Second tab should not have same bounds as first tab";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
// test Page.getAccessibleStateSet
|
||||
// At this point page 0 is selected
|
||||
AccessibleStateSet accSS0 = pac0.getAccessibleStateSet();
|
||||
if (!accSS0.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Empty title -> AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// select second tab
|
||||
badPane.setSelectedIndex(1);
|
||||
AccessibleStateSet accSS1 = pac1.getAccessibleStateSet();
|
||||
if (!accSS1.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Second tab selected but AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// select third tab
|
||||
badPane.setSelectedIndex(2);
|
||||
AccessibleStateSet accSS2 = pac2.getAccessibleStateSet();
|
||||
if (!accSS1.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Third tab selected but AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// select fourth tab
|
||||
badPane.setSelectedIndex(3);
|
||||
AccessibleStateSet accSS3 = pac3.getAccessibleStateSet();
|
||||
if (!accSS1.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Fourth tab selected but AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// test Page.getAccessibleStateSet
|
||||
// At this point page 0 is selected
|
||||
AccessibleStateSet accSS0 = pac0.getAccessibleStateSet();
|
||||
if (!accSS0.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Empty title -> AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// select second tab
|
||||
badPane.setSelectedIndex(1);
|
||||
AccessibleStateSet accSS1 = pac1.getAccessibleStateSet();
|
||||
if (!accSS1.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Second tab selected but AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// select third tab
|
||||
badPane.setSelectedIndex(2);
|
||||
AccessibleStateSet accSS2 = pac2.getAccessibleStateSet();
|
||||
if (!accSS1.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Third tab selected but AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// select fourth tab
|
||||
badPane.setSelectedIndex(3);
|
||||
AccessibleStateSet accSS3 = pac3.getAccessibleStateSet();
|
||||
if (!accSS1.contains(AccessibleState.SELECTED)) {
|
||||
String msg = "Fourth tab selected but AccessibleState.SELECTED not set";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
// test Page.getAccessibleIndexInParent
|
||||
if (pac0.getAccessibleIndexInParent() == -1) {
|
||||
String msg = "Empty title -> negative AccessibleIndexInParent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac0.getAccessibleIndexInParent() != 0) {
|
||||
String msg = "first tab is not at index 0 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac1.getAccessibleIndexInParent() != 1) {
|
||||
String msg = "second tab (null component) is not at index 1 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac2.getAccessibleIndexInParent() != 2) {
|
||||
String msg = "third tab (empty title) string is not at index 2 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac3.getAccessibleIndexInParent() != 3) {
|
||||
String msg = "fourth tab (empty title, null component, has tabComponent) string is not at index 3 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// test Page.getAccessibleIndexInParent
|
||||
if (pac0.getAccessibleIndexInParent() == -1) {
|
||||
String msg = "Empty title -> negative AccessibleIndexInParent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac0.getAccessibleIndexInParent() != 0) {
|
||||
String msg = "first tab is not at index 0 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac1.getAccessibleIndexInParent() != 1) {
|
||||
String msg = "second tab (null component) is not at index 1 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac2.getAccessibleIndexInParent() != 2) {
|
||||
String msg = "third tab (empty title) string is not at index 2 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (pac3.getAccessibleIndexInParent() != 3) {
|
||||
String msg = "fourth tab (empty title, null component, has tabComponent) string is not at index 3 in parent";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
// test Page.getAccessibleName
|
||||
String accName = pac0.getAccessibleName();
|
||||
if (!accName.equals("zero")) {
|
||||
String msg = "Empty title -> empty AccessibleName";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// test Page.getAccessibleName when component is null
|
||||
accName = pac1.getAccessibleName();
|
||||
if (!accName.equals("one")) {
|
||||
String msg = "AccessibleName of null panel not 'one'";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// test Page.getAccessibleName
|
||||
String accName = pac0.getAccessibleName();
|
||||
if (!accName.equals("zero")) {
|
||||
String msg = "Empty title -> empty AccessibleName";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// test Page.getAccessibleName when component is null
|
||||
accName = pac1.getAccessibleName();
|
||||
if (!accName.equals("one")) {
|
||||
String msg = "AccessibleName of null panel not 'one'";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
// test Page.setDisplayedMnemonicIndex
|
||||
// Empty title -> IllegalArgumnetException
|
||||
badPane.setDisplayedMnemonicIndexAt(0, 1);
|
||||
// test Page.setDisplayedMnemonicIndex
|
||||
// Empty title -> IllegalArgumnetException
|
||||
badPane.setDisplayedMnemonicIndexAt(0, 1);
|
||||
|
||||
// test Page.updateDisplayedMnemonicIndex
|
||||
badPane.setMnemonicAt(0, KeyEvent.VK_Z);
|
||||
if (badPane.getDisplayedMnemonicIndexAt(0) == -1) {
|
||||
String msg="Empty title -> getDisplayedMnemonicIndexAt failure";
|
||||
throw new RuntimeException(msg);
|
||||
// test Page.updateDisplayedMnemonicIndex
|
||||
badPane.setMnemonicAt(0, KeyEvent.VK_Z);
|
||||
if (badPane.getDisplayedMnemonicIndexAt(0) == -1) {
|
||||
String msg="Empty title -> getDisplayedMnemonicIndexAt failure";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
exception = e;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
exception = e;
|
||||
});
|
||||
if (exception != null) {
|
||||
System.out.println("Test failed: " + exception.getMessage());
|
||||
throw exception;
|
||||
} else {
|
||||
System.out.println("Test passed.");
|
||||
}
|
||||
});
|
||||
if (exception != null) {
|
||||
System.out.println("Test failed: " + exception.getMessage());
|
||||
throw exception;
|
||||
} else {
|
||||
System.out.println("Test passed.");
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,40 +43,45 @@ import javax.swing.border.LineBorder;
|
||||
public class bug4220171 {
|
||||
|
||||
private static JTable table;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
try {
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
|
||||
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
public void run() {
|
||||
createAndShowGUI();
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.waitForIdle();
|
||||
|
||||
clickMouse(robot, 0, 0);
|
||||
Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(0, 0);
|
||||
clickMouse(robot, 0, 0);
|
||||
Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(0, 0);
|
||||
|
||||
clickMouse(robot, 0, 1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(0, 1);
|
||||
clickMouse(robot, 0, 1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(0, 1);
|
||||
|
||||
clickMouse(robot, 1, 0);
|
||||
Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(1, 0);
|
||||
clickMouse(robot, 1, 0);
|
||||
Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(1, 0);
|
||||
|
||||
clickMouse(robot, 1, 1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(1, 1);
|
||||
clickMouse(robot, 1, 1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
checkCell(1, 1);
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
static void checkCell(final int row, final int column) throws Exception {
|
||||
@ -116,7 +121,7 @@ public class bug4220171 {
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame frame = new JFrame("Test");
|
||||
frame = new JFrame("Test");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(200, 200);
|
||||
|
||||
|
||||
@ -43,45 +43,49 @@ public class bug6777378 {
|
||||
private static JTableHeader header;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(20);
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JTable table = new JTable(new AbstractTableModel() {
|
||||
public int getRowCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
return "" + rowIndex + " " + columnIndex;
|
||||
}
|
||||
});
|
||||
|
||||
header = new JTableHeader(table.getColumnModel());
|
||||
header.setToolTipText("hello");
|
||||
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.add(header);
|
||||
|
||||
frame.setSize(300, 300);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
JTable table = new JTable(new AbstractTableModel() {
|
||||
public int getRowCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
return "" + rowIndex + " " + columnIndex;
|
||||
}
|
||||
});
|
||||
|
||||
header = new JTableHeader(table.getColumnModel());
|
||||
header.setToolTipText("hello");
|
||||
|
||||
frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.add(header);
|
||||
|
||||
frame.setSize(300, 300);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point point = header.getLocationOnScreen();
|
||||
robot.mouseMove(point.x + 20, point.y + 50);
|
||||
robot.mouseMove(point.x + 30, point.y + 50);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
});
|
||||
robot.waitForIdle();
|
||||
Point point = header.getLocationOnScreen();
|
||||
robot.mouseMove(point.x + 20, point.y + 50);
|
||||
robot.mouseMove(point.x + 30, point.y + 50);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
} finally {
|
||||
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user