jdk/test/java/awt/event/MouseEvent/AWTPanelSmoothWheel/AWTPanelSmoothWheel.java
author dcherepanov
Mon, 23 Mar 2009 09:47:39 -0400
changeset 2469 c71d7365daf1
child 5506 202f599c92aa
permissions -rw-r--r--
6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported Reviewed-by: art, dav
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2469
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     1
/*
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     4
 *
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     8
 *
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    13
 * accompanied this code).
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    14
 *
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    18
 *
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    21
 * have any questions.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    22
 */
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    23
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    24
/*
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    25
  test
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    26
  @bug 6730447
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    27
  @summary Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    28
  @author dmitry.cherepanov@...: area=awt.mouse
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    29
  @run applet/manual=yesno AWTPanelSmoothWheel.html
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    30
*/
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    31
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    32
/**
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    33
 * AWTPanelSmoothWheel.java
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    34
 *
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    35
 * summary:
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    36
 */
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    37
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    38
import java.applet.Applet;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    39
import java.awt.*;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    40
import java.awt.event.*;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    41
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    42
//Manual tests should run as applet tests if possible because they
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    43
// get their environments cleaned up, including AWT threads, any
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    44
// test created threads, and any system resources used by the test
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    45
// such as file descriptors.  (This is normally not a problem as
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    46
// main tests usually run in a separate VM, however on some platforms
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    47
// such as the Mac, separate VMs are not possible and non-applet
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    48
// tests will cause problems).  Also, you don't have to worry about
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    49
// synchronisation stuff in Applet tests the way you do in main
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    50
// tests...
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    51
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    52
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    53
public class AWTPanelSmoothWheel extends Applet
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    54
{
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    55
    //Declare things used in the test, like buttons and labels here
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    56
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    57
    public void init()
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    58
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    59
        //Create instructions for the user here, as well as set up
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    60
        // the environment -- set the layout manager, add buttons,
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    61
        // etc.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    62
        this.setLayout (new BorderLayout ());
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    63
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    64
        String[] instructions =
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    65
        {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    66
            " the test is relevant for windows platforms and ",
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    67
            " mouses with high-resolution wheel, please just press pass if it's not the case ",
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    68
            " place the mouse cursor above the green panel and rotate the mouse wheel " ,
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    69
            " the test will print all mouse wheel messages into the logging panel, ",
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    70
            " please make sure that some of the messages have non-zero 'wheelRotation' value ",
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    71
            " in this case the test passes, otherwise it fails, ",
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    72
            " please make sure the test works OK if the mouse wheel is rotated very slow  "
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    73
        };
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    74
        Sysout.createDialogWithInstructions( instructions );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    75
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    76
    }//End  init()
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    77
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    78
    public void start ()
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    79
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    80
        Panel panel = new Panel();
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    81
        panel.setBackground(Color.green);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    82
        panel.addMouseWheelListener(new MouseWheelListener() {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    83
            public void mouseWheelMoved(MouseWheelEvent e) {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    84
                Sysout.println(e.toString());
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    85
            }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    86
        });
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    87
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    88
        //Get things going.  Request focus, set size, et cetera
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    89
        setSize (200,200);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    90
        setLayout(new BorderLayout());
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    91
        add(panel, BorderLayout.CENTER);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    92
        setVisible(true);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    93
        validate();
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    94
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    95
        //What would normally go into main() will probably go here.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    96
        //Use System.out.println for diagnostic messages that you want
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    97
        // to read after the test is done.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    98
        //Use Sysout.println for messages you want the tester to read.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
    99
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   100
    }// start()
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   101
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   102
    //The rest of this class is the actions which perform the test...
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   103
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   104
    //Use Sysout.println to communicate with the user NOT System.out!!
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   105
    //Sysout.println ("Something Happened!");
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   106
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   107
}// class ManualYesNoTest
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   108
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   109
/* Place other classes related to the test after this line */
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   110
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   111
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   112
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   113
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   114
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   115
/****************************************************
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   116
 Standard Test Machinery
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   117
 DO NOT modify anything below -- it's a standard
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   118
  chunk of code whose purpose is to make user
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   119
  interaction uniform, and thereby make it simpler
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   120
  to read and understand someone else's test.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   121
 ****************************************************/
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   122
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   123
/**
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   124
 This is part of the standard test machinery.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   125
 It creates a dialog (with the instructions), and is the interface
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   126
  for sending text messages to the user.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   127
 To print the instructions, send an array of strings to Sysout.createDialog
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   128
  WithInstructions method.  Put one line of instructions per array entry.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   129
 To display a message for the tester to see, simply call Sysout.println
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   130
  with the string to be displayed.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   131
 This mimics System.out.println but works within the test harness as well
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   132
  as standalone.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   133
 */
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   134
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   135
class Sysout
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   136
{
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   137
    private static TestDialog dialog;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   138
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   139
    public static void createDialogWithInstructions( String[] instructions )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   140
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   141
        dialog = new TestDialog( new Frame(), "Instructions" );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   142
        dialog.printInstructions( instructions );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   143
        dialog.setVisible(true);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   144
        println( "Any messages for the tester will display here." );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   145
    }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   146
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   147
    public static void createDialog( )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   148
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   149
        dialog = new TestDialog( new Frame(), "Instructions" );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   150
        String[] defInstr = { "Instructions will appear here. ", "" } ;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   151
        dialog.printInstructions( defInstr );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   152
        dialog.setVisible(true);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   153
        println( "Any messages for the tester will display here." );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   154
    }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   155
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   156
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   157
    public static void printInstructions( String[] instructions )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   158
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   159
        dialog.printInstructions( instructions );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   160
    }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   161
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   162
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   163
    public static void println( String messageIn )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   164
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   165
        dialog.displayMessage( messageIn );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   166
    }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   167
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   168
}// Sysout  class
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   169
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   170
/**
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   171
  This is part of the standard test machinery.  It provides a place for the
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   172
   test instructions to be displayed, and a place for interactive messages
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   173
   to the user to be displayed.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   174
  To have the test instructions displayed, see Sysout.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   175
  To have a message to the user be displayed, see Sysout.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   176
  Do not call anything in this dialog directly.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   177
  */
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   178
class TestDialog extends Dialog
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   179
{
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   180
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   181
    TextArea instructionsText;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   182
    TextArea messageText;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   183
    int maxStringLength = 80;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   184
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   185
    //DO NOT call this directly, go through Sysout
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   186
    public TestDialog( Frame frame, String name )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   187
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   188
        super( frame, name );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   189
        int scrollBoth = TextArea.SCROLLBARS_BOTH;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   190
        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   191
        add( "North", instructionsText );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   192
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   193
        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   194
        add("Center", messageText);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   195
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   196
        pack();
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   197
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   198
        setVisible(true);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   199
    }// TestDialog()
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   200
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   201
    //DO NOT call this directly, go through Sysout
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   202
    public void printInstructions( String[] instructions )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   203
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   204
        //Clear out any current instructions
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   205
        instructionsText.setText( "" );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   206
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   207
        //Go down array of instruction strings
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   208
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   209
        String printStr, remainingStr;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   210
        for( int i=0; i < instructions.length; i++ )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   211
        {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   212
            //chop up each into pieces maxSringLength long
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   213
            remainingStr = instructions[ i ];
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   214
            while( remainingStr.length() > 0 )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   215
            {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   216
                //if longer than max then chop off first max chars to print
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   217
                if( remainingStr.length() >= maxStringLength )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   218
                {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   219
                    //Try to chop on a word boundary
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   220
                    int posOfSpace = remainingStr.
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   221
                        lastIndexOf( ' ', maxStringLength - 1 );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   222
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   223
                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   224
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   225
                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   226
                    remainingStr = remainingStr.substring( posOfSpace + 1 );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   227
                }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   228
                //else just print
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   229
                else
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   230
                {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   231
                    printStr = remainingStr;
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   232
                    remainingStr = "";
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   233
                }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   234
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   235
                instructionsText.append( printStr + "\n" );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   236
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   237
            }// while
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   238
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   239
        }// for
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   240
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   241
    }//printInstructions()
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   242
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   243
    //DO NOT call this directly, go through Sysout
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   244
    public void displayMessage( String messageIn )
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   245
    {
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   246
        messageText.append( messageIn + "\n" );
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   247
        System.out.println(messageIn);
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   248
    }
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   249
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   250
}// TestDialog  class
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents:
diff changeset
   251