< prev index next >
jdk/test/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2007, 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.
--- 1,7 ----
/*
! * Copyright (c) 2007, 2015 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.
*** 21,31 ****
* questions.
*/
/*
@test
! @bug 6566434
@library ../../regtesthelpers
@build Util Sysout AbstractTest
@summary Choice in unfocusable window responds to keyboard
@author Andrei Dmitriev: area=awt-choice
@run main UnfocusableToplevel
--- 21,31 ----
* questions.
*/
/*
@test
! @bug 6566434 8039467
@library ../../regtesthelpers
@build Util Sysout AbstractTest
@summary Choice in unfocusable window responds to keyboard
@author Andrei Dmitriev: area=awt-choice
@run main UnfocusableToplevel
*** 61,70 ****
--- 61,82 ----
ch.add("item 5");
w.add(ch);
w.setLayout(new FlowLayout());
w.setSize(200, 200);
+ // 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.setVisible(true);
+ Util.waitForIdle(robot);
+
+ tempFrameToHoldFocus.requestFocus();
+ Util.clickOnComp(tempFrameToHoldFocus, robot);
+ Util.waitForIdle(robot);
+
ch.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent e){
traceEvent("keytyped", e);
}
public void keyPressed(KeyEvent e){
*** 92,101 ****
--- 104,117 ----
// technique to accomplish that rather then checking color of dropdown
// Will suppose that the dropdown appears
testKeys();
Util.waitForIdle(robot);
+
+ tempFrameToHoldFocus.dispose();
+ w.dispose();
+ f.dispose();
}
private static void testKeys(){
typeKey(KeyEvent.VK_UP);
typeKey(KeyEvent.VK_DOWN);
< prev index next >