< prev index next >

test/jdk/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2020, 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.

@@ -36,14 +36,22 @@
  * UnfocusableToplevel.java
  *
  * summary:
  */
 
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.AWTEvent;
+import java.awt.Choice;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Robot;
+import java.awt.Window;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+
 import test.java.awt.regtesthelpers.AbstractTest;
-import test.java.awt.regtesthelpers.Sysout;
 import test.java.awt.regtesthelpers.Util;
 
 public class UnfocusableToplevel {
 
     final static Robot robot = Util.createRobot();

@@ -67,10 +75,12 @@
         // Note that Window w is non focusable. Key press events will not be
         // consumed by w, but by any previously focused window & this can
         // disturb the environment. So creating tempFrameToHoldFocus frame,
         // to consume key press events.
         Frame tempFrameToHoldFocus = new Frame();
+        tempFrameToHoldFocus.setSize(300, 300);
+        tempFrameToHoldFocus.setLocationRelativeTo(null);
         tempFrameToHoldFocus.setVisible(true);
         Util.waitForIdle(robot);
 
         tempFrameToHoldFocus.requestFocus();
         Util.clickOnComp(tempFrameToHoldFocus, robot);

@@ -91,11 +101,11 @@
         ch.addItemListener(new ItemListener(){
                 public void itemStateChanged(ItemEvent ie){
                     traceEvent("stateChanged", ie);
                 }
             });
-
+        w.setLocationRelativeTo(null);
         w.setVisible(true);
 
         Util.waitForIdle(robot);
 
         Util.clickOnComp(ch, robot);
< prev index next >