< prev index next >

test/jdk/java/awt/Mouse/TitleBarDoubleClick/TitleBarDoubleClick.java

Print this page


   1 /*
   2  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 4664415
  27   @summary REGRESSION: double click jframe titlebar generating mouse events in panel
  28   @author Andrei Dmitriev: area=awt.mouse
  29   @run applet TitleBarDoubleClick.html

  30 */
  31 import java.applet.Applet;
  32 import java.awt.*;
  33 import java.awt.event.*;
  34 import test.java.awt.regtesthelpers.Util;
  35 
  36 public class TitleBarDoubleClick extends Applet implements MouseListener,
  37  WindowListener
  38 {
  39     //Declare things used in the test, like buttons and labels here
  40     private final static Rectangle BOUNDS = new Rectangle(300, 300, 300, 300);
  41     private final static int TITLE_BAR_OFFSET = 10;
  42 
  43     Frame frame;
  44     Robot robot;
  45 
  46     public void init()
  47     {
  48         this.setLayout (new BorderLayout ());
  49 
  50     }//End  init()
  51 
  52     public void start ()
  53     {
  54         //Get things going.  Request focus, set size, et cetera
  55         setSize (200,200);
  56         setVisible(true);
  57         validate();
  58 
  59         //What would normally go into main() will probably go here.
  60         //Use System.out.println for diagnostic messages that you want
  61         //to read after the test is done.
  62         //Use Sysout.println for messages you want the tester to read.
  63 
  64             robot = Util.createRobot();
  65             robot.setAutoDelay(100);
  66             robot.mouseMove(BOUNDS.x + (BOUNDS.width / 2),
  67                             BOUNDS.y + (BOUNDS.height/ 2));
  68 
  69             frame = new Frame("TitleBarDoubleClick");
  70             frame.setBounds(BOUNDS);
  71             frame.addMouseListener(this);
  72             frame.addWindowListener(this);
  73             frame.setVisible(true);
  74     }// start()
  75 
  76     // Move the mouse into the title bar and double click to maximize the
  77     // Frame
  78     static boolean hasRun = false;
  79 
  80     private void doTest() {
  81         if (hasRun) return;
  82         hasRun = true;
  83 


   1 /*
   2  * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 4664415
  28   @summary Test that double clicking the titlebar does not send RELEASE/CLICKED
  29   @library    ../../regtesthelpers
  30   @build      Util
  31   @run main TitleBarDoubleClick
  32 */
  33 
  34 import java.awt.*;
  35 import java.awt.event.*;
  36 import test.java.awt.regtesthelpers.Util;
  37 
  38 public class TitleBarDoubleClick implements MouseListener,
  39  WindowListener
  40 {
  41     //Declare things used in the test, like buttons and labels here
  42     private final static Rectangle BOUNDS = new Rectangle(300, 300, 300, 300);
  43     private final static int TITLE_BAR_OFFSET = 10;
  44 
  45     Frame frame;
  46     Robot robot;
  47 
  48     public static void main(final String[] args) {
  49         TitleBarDoubleClick app = new TitleBarDoubleClick();
  50         app.start();
  51     }

  52 
  53     public void start ()
  54     {










  55             robot = Util.createRobot();
  56             robot.setAutoDelay(100);
  57             robot.mouseMove(BOUNDS.x + (BOUNDS.width / 2),
  58                             BOUNDS.y + (BOUNDS.height/ 2));
  59 
  60             frame = new Frame("TitleBarDoubleClick");
  61             frame.setBounds(BOUNDS);
  62             frame.addMouseListener(this);
  63             frame.addWindowListener(this);
  64             frame.setVisible(true);
  65     }// start()
  66 
  67     // Move the mouse into the title bar and double click to maximize the
  68     // Frame
  69     static boolean hasRun = false;
  70 
  71     private void doTest() {
  72         if (hasRun) return;
  73         hasRun = true;
  74 


< prev index next >