1 /* 2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @key headful 27 @bug 6607170 28 @summary Tests for focus-auto-transfer. 29 @author Anton Tarasov: area=awt-focus 30 @library ../../regtesthelpers 31 @build Util 32 @run main ContainerFocusAutoTransferTest 33 */ 34 35 import java.applet.Applet; 36 import java.awt.AWTEvent; 37 import java.awt.Component; 38 import java.awt.ComponentOrientation; 39 import java.awt.DefaultKeyboardFocusManager; 40 import java.awt.KeyboardFocusManager; 41 import java.awt.Robot; 42 import java.awt.Color; 43 import java.awt.FlowLayout; 44 import java.awt.Toolkit; 45 import java.awt.event.AWTEventListener; 46 import java.awt.event.FocusEvent; 47 import java.awt.event.WindowEvent; 48 import javax.swing.JButton; 49 import javax.swing.JFrame; 50 import javax.swing.JPanel; 51 import test.java.awt.regtesthelpers.Util; 52 53 public class ContainerFocusAutoTransferTest extends Applet { 54 Robot robot; 55 TestFrame frame; 56 KeyboardFocusManager kfm; 57 enum TestCase { 58 REMOVAL { public String toString() { return "removal"; } }, 59 HIDING { public String toString() { return "hiding"; } }, 60 DISABLING { public String toString() { return "disabling"; } }, 61 DEFOCUSING { public String toString() { return "defocusing"; } }; 62 public abstract String toString(); 63 }; 64 65 public static void main(String[] args) { 66 ContainerFocusAutoTransferTest app = new ContainerFocusAutoTransferTest(); 67 app.init(); 68 app.start(); 69 } 70 71 public void init() { 72 robot = Util.createRobot(); 73 kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); | 1 /* 2 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @key headful 27 @bug 6607170 28 @summary Tests for focus-auto-transfer. 29 @library ../../regtesthelpers 30 @build Util 31 @run main ContainerFocusAutoTransferTest 32 */ 33 34 import java.awt.AWTEvent; 35 import java.awt.Component; 36 import java.awt.ComponentOrientation; 37 import java.awt.DefaultKeyboardFocusManager; 38 import java.awt.KeyboardFocusManager; 39 import java.awt.Robot; 40 import java.awt.Color; 41 import java.awt.FlowLayout; 42 import java.awt.Toolkit; 43 import java.awt.event.AWTEventListener; 44 import java.awt.event.FocusEvent; 45 import java.awt.event.WindowEvent; 46 import javax.swing.JButton; 47 import javax.swing.JFrame; 48 import javax.swing.JPanel; 49 import test.java.awt.regtesthelpers.Util; 50 51 public class ContainerFocusAutoTransferTest { 52 Robot robot; 53 TestFrame frame; 54 KeyboardFocusManager kfm; 55 enum TestCase { 56 REMOVAL { public String toString() { return "removal"; } }, 57 HIDING { public String toString() { return "hiding"; } }, 58 DISABLING { public String toString() { return "disabling"; } }, 59 DEFOCUSING { public String toString() { return "defocusing"; } }; 60 public abstract String toString(); 61 }; 62 63 public static void main(String[] args) { 64 ContainerFocusAutoTransferTest app = new ContainerFocusAutoTransferTest(); 65 app.init(); 66 app.start(); 67 } 68 69 public void init() { 70 robot = Util.createRobot(); 71 kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); |