0N/A/*
2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A/*
0N/A test
0N/A @bug 6533175
0N/A @summary Block F10 if closest toplevel to keystroke target is not a Frame.
0N/A @author yuri nesterenko : area=awt.toplevel
0N/A @run applet F10TopToplevel.html
0N/A*/
0N/A
0N/A
0N/A
0N/A/**
0N/A * F10TopToplevel.java
0N/A *
0N/A * summary: tests if F10 has no effect if focused toplevel if not Frame
0N/A */
0N/A
0N/Aimport java.applet.Applet;
0N/Aimport java.awt.*;
0N/Aimport java.awt.event.*;
0N/A
0N/A
0N/Apublic class F10TopToplevel extends Applet
0N/A{
0N/A //Declare things used in the test, like buttons and labels here
0N/A Frame frame;
0N/A Dialog dialog;
0N/A volatile boolean menuToggled = false;
0N/A
0N/A public void init()
0N/A {
0N/A setLayout (new BorderLayout ());
0N/A
0N/A }//End init()
0N/A
0N/A public void start ()
0N/A {
0N/A //Get things going. Request focus, set size, et cetera
0N/A setSize (200,200);
0N/A setVisible(true);
0N/A validate();
0N/A
0N/A
0N/A //What would normally go into main() will probably go here.
0N/A //Use System.out.println for diagnostic messages that you want
0N/A //to read after the test is done.
0N/A MenuBar mb;
0N/A Menu menu;
0N/A MenuItem item;
0N/A frame = new Frame("am below");
0N/A frame.setMenuBar( (mb=new MenuBar()) );
0N/A menu = new Menu("nu");
0N/A menu.add((item = new MenuItem("item")));
0N/A item.addActionListener( new ActionListener() {
0N/A public void actionPerformed( ActionEvent ae ) {
0N/A menuToggled = true;
0N/A }
0N/A });
0N/A mb.add(menu);
0N/A
0N/A frame.setSize(200,200);
0N/A frame.setLocation( 400,100 );
0N/A frame.setVisible( true );
0N/A
0N/A dialog = new Dialog(frame);
0N/A dialog.setSize( 100,100 );
0N/A dialog.setVisible(true);
0N/A
0N/A Robot robot;
0N/A try {
0N/A robot = new Robot();
0N/A } catch(AWTException e){
0N/A throw new RuntimeException("cannot create robot.", e);
0N/A }
0N/A ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
0N/A robot.mouseMove(dialog.getLocationOnScreen().x + dialog.getWidth()/2,
0N/A dialog.getLocationOnScreen().y + dialog.getHeight()/2 );
0N/A robot.delay(5);
0N/A robot.mousePress(InputEvent.BUTTON1_MASK);
0N/A robot.delay(5);
0N/A robot.mouseRelease(InputEvent.BUTTON1_MASK);
0N/A robot.delay(5);
0N/A robot.keyPress(KeyEvent.VK_F10);
0N/A robot.delay(5);
0N/A robot.keyRelease(KeyEvent.VK_F10);
0N/A robot.delay(5);
0N/A
0N/A robot.delay(10);
0N/A robot.keyPress(KeyEvent.VK_ENTER);
0N/A robot.delay(5);
0N/A robot.keyRelease(KeyEvent.VK_ENTER);
0N/A robot.delay(5);
0N/A
0N/A ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
0N/A
0N/A if(menuToggled) {
0N/A throw new RuntimeException("Oops! Menu should not open.");
0N/A }
0N/A
0N/A }// start()
0N/A
0N/A}// class F10TopToplevel