test/jdk/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.java
changeset 54231 e4813eded7cb
parent 47216 71c04702a3d5
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25   test
    25   @test
       
    26   @key headful
    26   @bug        5082319
    27   @bug        5082319
    27   @summary    Tests that focus request for already focused component doesn't block key events.
    28   @summary    Tests that focus request for already focused component doesn't block key events.
    28   @author     anton.tarasov@sun.com
    29   @run main FocusSubRequestTest
    29   @run applet FocusSubRequestTest.html
       
    30 */
    30 */
    31 
    31 
    32 import java.applet.Applet;
       
    33 import java.awt.*;
    32 import java.awt.*;
    34 import java.awt.event.*;
    33 import java.awt.event.*;
    35 
    34 
    36 public class FocusSubRequestTest extends Applet {
    35 public class FocusSubRequestTest {
    37     Frame frame = new Frame("Test Frame");
    36     Frame frame = new Frame("Test Frame");
    38     Button button = new Button("button");
    37     Button button = new Button("button");
    39     boolean passed = false;
    38     boolean passed = false;
    40     Robot robot;
    39     Robot robot;
       
    40 
       
    41     public static void main(final String[] args) {
       
    42         FocusSubRequestTest app = new FocusSubRequestTest();
       
    43         app.init();
       
    44         app.start();
       
    45     }
    41 
    46 
    42     public void init() {
    47     public void init() {
    43         frame.add(button);
    48         frame.add(button);
    44         button.addFocusListener(new FocusAdapter() {
    49         button.addFocusListener(new FocusAdapter() {
    45                 public void focusGained(FocusEvent e) {
    50                 public void focusGained(FocusEvent e) {
    62         }
    67         }
    63     }
    68     }
    64 
    69 
    65     public void start() {
    70     public void start() {
    66         frame.pack();
    71         frame.pack();
    67         frame.setLocation(getLocation().x + getSize().width + 20, 0);
    72         frame.setLocationRelativeTo(null);
    68         frame.setVisible(true);
    73         frame.setVisible(true);
    69 
    74 
    70         waitTillShown(button);
    75         waitTillShown(button);
    71         frame.toFront();
    76         frame.toFront();
    72 
    77