< prev index next >

test/jdk/java/awt/Focus/ModalExcludedWindowClickTest/ModalExcludedWindowClickTest.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       6271849
  27   @summary   Tests that component in modal excluded Window which parent is blocked responses to mouse clicks.
  28   @author    anton.tarasov@sun.com: area=awt.focus
  29   @run       applet ModalExcludedWindowClickTest.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 ModalExcludedWindowClickTest extends Applet {
  38     Robot robot;
  39     Frame frame = new Frame("Frame");
  40     Window w = new Window(frame);
  41     Dialog d = new Dialog ((Dialog)null, "NullParentDialog", true);
  42     Button button = new Button("Button");
  43     boolean actionPerformed = false;
  44 
  45     public static void main (String args[]) {
  46         ModalExcludedWindowClickTest app = new ModalExcludedWindowClickTest();
  47         app.init();
  48         app.start();
  49     }
  50 
  51     public void init() {
  52         try {
  53             robot = new Robot();
  54         } catch (AWTException e) {
  55             throw new RuntimeException("Error: unable to create robot", e);
  56         }
  57         // Create instructions for the user here, as well as set up
  58         // the environment -- set the layout manager, add buttons,
  59         // etc.
  60         this.setLayout (new BorderLayout ());
  61     }
  62 
  63     public void start() {
  64 
  65         if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
  66             System.out.println("No testing on MToolkit.");
  67             return;
  68         }
  69 
  70         button.addActionListener(new ActionListener() {
  71                 public void actionPerformed(ActionEvent e) {
  72                     actionPerformed = true;
  73                     System.out.println(e.paramString());
  74                 }
  75             });
  76 
  77         EventQueue.invokeLater(new Runnable() {
  78                 public void run() {
  79                     frame.setSize(200, 200);
  80                     frame.setVisible(true);




   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        6271849
  28   @summary    Tests that component in modal excluded Window which parent is blocked responses to mouse clicks.
  29   @modules java.desktop/sun.awt
  30   @run        main ModalExcludedWindowClickTest
  31 */
  32 

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




  57     }
  58 
  59     public void start() {
  60 
  61         if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
  62             System.out.println("No testing on MToolkit.");
  63             return;
  64         }
  65 
  66         button.addActionListener(new ActionListener() {
  67                 public void actionPerformed(ActionEvent e) {
  68                     actionPerformed = true;
  69                     System.out.println(e.paramString());
  70                 }
  71             });
  72 
  73         EventQueue.invokeLater(new Runnable() {
  74                 public void run() {
  75                     frame.setSize(200, 200);
  76                     frame.setVisible(true);


< prev index next >