< prev index next >
test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -25,13 +25,13 @@
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import javax.swing.BoxLayout;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
+import java.lang.reflect.InvocationTargetException;
+import javax.swing.*;
+
import test.java.awt.regtesthelpers.Util;
/**
* AWT/Swing overlapping test for {@link javax.swing.JCombobox } component.
@@ -53,20 +53,22 @@
public class JComboBoxOverlapping extends OverlappingTestBase {
private boolean lwClicked = false;
private Point loc;
private Point loc2;
+ private JComboBox cb;
+ private JFrame frame;
{testEmbeddedFrame = true;}
protected void prepareControls() {
- final JFrame frame = new JFrame("Mixing : Dropdown Overlapping test");
+ frame = new JFrame("Mixing : Dropdown Overlapping test");
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
frame.setSize(200, 200);
frame.setVisible(true);
- final JComboBox cb = new JComboBox(petStrings);
+ cb = new JComboBox(petStrings);
cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));
cb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cb) {
@@ -76,19 +78,27 @@
});
frame.add(cb);
propagateAWTControls(frame);
frame.setVisible(true);
- loc = cb.getLocationOnScreen();
- loc2 = frame.getContentPane().getLocationOnScreen();
}
@Override
protected boolean performTest() {
// run robot
Robot robot = Util.createRobot();
robot.setAutoDelay(ROBOT_DELAY);
+ robot.waitForIdle();
+ robot.delay(200);
+ try {
+ SwingUtilities.invokeAndWait(() -> {
+ loc = cb.getLocationOnScreen();
+ loc2 = frame.getContentPane().getLocationOnScreen();
+ });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
loc2.translate(75, 75);
pixelPreCheck(robot, loc2, currentAwtControl);
loc.translate(3, 3);
< prev index next >