test/jdk/java/awt/Component/F10TopToplevel/F10TopToplevel.java
changeset 54231 e4813eded7cb
parent 47216 71c04702a3d5
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
     1 /*
     1 /*
     2  * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2007, 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.
    18  *
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
       
    23 
    23 /*
    24 /*
    24   test
    25   @test
       
    26   @key headful
    25   @bug 6533175
    27   @bug 6533175
    26   @summary Block F10 if closest toplevel to keystroke target is not a Frame.
    28   @summary Block F10 if closest toplevel to keystroke target is not a Frame.
    27   @author yuri nesterenko : area=awt.toplevel
    29   @run main F10TopToplevel
    28   @run applet F10TopToplevel.html
       
    29 */
    30 */
    30 
    31 
    31 
       
    32 
       
    33 /**
       
    34  * F10TopToplevel.java
       
    35  *
       
    36  * summary: tests if F10 has no effect if focused toplevel if not Frame
       
    37  */
       
    38 
       
    39 import java.applet.Applet;
       
    40 import java.awt.*;
    32 import java.awt.*;
    41 import java.awt.event.*;
    33 import java.awt.event.*;
    42 
    34 
       
    35 public class F10TopToplevel {
    43 
    36 
    44 public class F10TopToplevel extends Applet
    37     static Frame frame;
    45 {
    38     static Dialog dialog;
    46     //Declare things used in the test, like buttons and labels here
    39     static volatile boolean menuToggled = false;
    47     Frame frame;
       
    48     Dialog dialog;
       
    49     volatile boolean menuToggled = false;
       
    50 
    40 
    51     public void init()
    41     public static void main(final String[] args) {
    52     {
       
    53         setLayout (new BorderLayout ());
       
    54 
       
    55     }//End  init()
       
    56 
       
    57     public void start ()
       
    58     {
       
    59         //Get things going.  Request focus, set size, et cetera
       
    60         setSize (200,200);
       
    61         setVisible(true);
       
    62         validate();
       
    63 
       
    64 
       
    65         //What would normally go into main() will probably go here.
       
    66         //Use System.out.println for diagnostic messages that you want
       
    67         //to read after the test is done.
       
    68         MenuBar mb;
    42         MenuBar mb;
    69         Menu menu;
    43         Menu menu;
    70         MenuItem item;
    44         MenuItem item;
    71         frame = new Frame("am below");
    45         frame = new Frame("am below");
    72         frame.setMenuBar( (mb=new MenuBar()) );
    46         frame.setMenuBar( (mb=new MenuBar()) );
   113 
    87 
   114         if(menuToggled) {
    88         if(menuToggled) {
   115             throw new RuntimeException("Oops! Menu should not open.");
    89             throw new RuntimeException("Oops! Menu should not open.");
   116         }
    90         }
   117 
    91 
   118     }// start()
    92     }
   119 
       
   120 }// class F10TopToplevel
    93 }// class F10TopToplevel