< prev index next >

test/jdk/java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.java

Print this page




   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   @bug       6272324
  27   @summary   Modal excluded Window which decorated parent is blocked should be non-focusable.
  28   @author    anton.tarasov@sun.com: area=awt.focus
  29   @run       applet NonFocusableBlockedOwnerTest.html
  30 */
  31 
  32 import java.applet.Applet;
  33 import java.awt.*;
  34 import java.awt.event.*;
  35 import java.lang.reflect.*;
  36 
  37 public class NonFocusableBlockedOwnerTest extends Applet {
  38     Robot robot;
  39     Frame frame = new Frame("Modal Blocked Frame");
  40     Dialog dialog = new Dialog(frame, "Modal Dialog", true);
  41     Window excluded = new Window(frame);
  42     Button button = new Button("button");
  43 
  44     public static void main(String[] args) {
  45         NonFocusableBlockedOwnerTest app = new NonFocusableBlockedOwnerTest();
  46         app.init();
  47         app.start();
  48     }
  49 
  50     public void init() {
  51         try {
  52             robot = new Robot();
  53         } catch (AWTException e) {
  54             throw new RuntimeException("Error: unable to create robot", e);
  55         }
  56         // Create instructions for the user here, as well as set up
  57         // the environment -- set the layout manager, add buttons,
  58         // etc.
  59         this.setLayout (new BorderLayout ());
  60     }
  61 
  62     public void start() {
  63 
  64         if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
  65             System.out.println("No testing on MToolkit.");
  66             return;
  67         }
  68 
  69         try {
  70             EventQueue.invokeLater(new Runnable() {
  71                 public void run() {
  72                     frame.setSize(300, 200);
  73                     frame.setVisible(true);
  74 
  75                     excluded.setSize(300, 200);
  76                     excluded.setLocation(0, 400);
  77                     excluded.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
  78                     excluded.setLayout(new FlowLayout());
  79                     excluded.add(button);




   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        6272324
  28   @summary    Modal excluded Window which decorated parent is blocked should be non-focusable.
  29   @modules java.desktop/sun.awt
  30   @run        main NonFocusableBlockedOwnerTest
  31 */
  32 

  33 import java.awt.*;
  34 import java.awt.event.*;
  35 import java.lang.reflect.*;
  36 
  37 public class NonFocusableBlockedOwnerTest {
  38     Robot robot;
  39     Frame frame = new Frame("Modal Blocked Frame");
  40     Dialog dialog = new Dialog(frame, "Modal Dialog", true);
  41     Window excluded = new Window(frame);
  42     Button button = new Button("button");
  43 
  44     public static void main(String[] args) {
  45         NonFocusableBlockedOwnerTest app = new NonFocusableBlockedOwnerTest();
  46         app.init();
  47         app.start();
  48     }
  49 
  50     public void init() {
  51         try {
  52             robot = new Robot();
  53         } catch (AWTException e) {
  54             throw new RuntimeException("Error: unable to create robot", e);
  55         }




  56     }
  57 
  58     public void start() {
  59 
  60         if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
  61             System.out.println("No testing on MToolkit.");
  62             return;
  63         }
  64 
  65         try {
  66             EventQueue.invokeLater(new Runnable() {
  67                 public void run() {
  68                     frame.setSize(300, 200);
  69                     frame.setVisible(true);
  70 
  71                     excluded.setSize(300, 200);
  72                     excluded.setLocation(0, 400);
  73                     excluded.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
  74                     excluded.setLayout(new FlowLayout());
  75                     excluded.add(button);


< prev index next >