jdk/test/java/awt/Mixing/MixingInHwPanel.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 32427 c22b7e41adf3
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2644
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 32427
diff changeset
     2
 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
2644
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     4
 *
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     7
 * published by the Free Software Foundation.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     8
 *
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    13
 * accompanied this code).
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    14
 *
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2644
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2644
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2644
diff changeset
    21
 * questions.
2644
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    22
 */
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    23
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    24
/*
18121
f2eb5e324296 7109977: [macosx] MixingInHwPanel.java test fails on Mac trying to click in the reserved corner
kshefov
parents: 5506
diff changeset
    25
  @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 32427
diff changeset
    26
  @key headful
2644
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    27
  @bug 6829858
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    28
  @summary Mixing should work inside heavyweight containers
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    29
  @author anthony.petrov@sun.com: area=awt.mixing
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    30
  @library ../regtesthelpers
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    31
  @build Util
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    32
  @run main MixingInHwPanel
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    33
*/
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    34
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    35
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    36
/**
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    37
 * MixingInHwPanel.java
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    38
 *
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    39
 * summary: Mixing should work inside heavyweight containers
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    40
 */
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    41
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    42
import java.awt.*;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    43
import java.awt.event.*;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    44
import javax.swing.*;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    45
import test.java.awt.regtesthelpers.Util;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    46
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    47
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    48
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    49
public class MixingInHwPanel
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    50
{
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    51
    static volatile boolean failed = true;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    52
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    53
    private static void init()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    54
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    55
        //*** Create instructions for the user here ***
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    56
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    57
        String[] instructions =
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    58
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    59
            "This is an AUTOMATIC test, simply wait until it is done.",
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    60
            "The result (passed or failed) will be shown in the",
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    61
            "message window below."
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    62
        };
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    63
        Sysout.createDialog( );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    64
        Sysout.printInstructions( instructions );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    65
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    66
        // Create the components: frame -> hwPanel -> JDesktopPane ->
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    67
        //    -> JInternalFrame -> hwButton
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    68
        Frame frame = new Frame("Mixing in a heavyweight Panel");
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    69
        frame.setBounds(100, 100, 640, 480);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    70
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    71
        Panel hwPanel = new Panel(new BorderLayout());
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    72
        frame.add(hwPanel);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    73
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    74
        JDesktopPane desktop = new JDesktopPane();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    75
        hwPanel.add(desktop);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    76
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    77
        JInternalFrame iFrame = new JInternalFrame("one",
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    78
                true, true, true, true);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    79
        iFrame.setPreferredSize(new Dimension(150, 55));
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    80
        iFrame.setBounds(600, 100, 150, 55);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    81
        iFrame.setVisible(true);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    82
        desktop.add(iFrame);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    83
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    84
        Button button = new Button("HW Button");
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    85
        button.addActionListener(new ActionListener() {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    86
            public void actionPerformed(ActionEvent e) {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    87
                failed = false;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    88
            }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    89
        });
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    90
        iFrame.add(button);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    91
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    92
        // Show the frame with the hwButton slightly hidden initially
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    93
        frame.setVisible(true);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    94
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    95
        Robot robot = Util.createRobot();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    96
        robot.setAutoDelay(20);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    97
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    98
        Util.waitForIdle(robot);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
    99
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   100
        // Now resize the frame so that the button is fully visible
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   101
        frame.setBounds(100, 100, 800, 480);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   102
        frame.validate();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   103
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   104
        Util.waitForIdle(robot);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   105
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   106
        // And click the part of the button that has been previously hidden
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   107
        Point bLoc = button.getLocationOnScreen();
18121
f2eb5e324296 7109977: [macosx] MixingInHwPanel.java test fails on Mac trying to click in the reserved corner
kshefov
parents: 5506
diff changeset
   108
        robot.mouseMove(bLoc.x + button.getWidth() - 15, bLoc.y + button.getHeight() / 2);
2644
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   109
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   110
        Util.waitForIdle(robot);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   111
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   112
        robot.mousePress(InputEvent.BUTTON1_MASK);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   113
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   114
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   115
        Util.waitForIdle(robot);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   116
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   117
        // If the click happens (the shape is reapplied), the button's action
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   118
        // listener will make failed == false.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   119
        if (failed) {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   120
            MixingInHwPanel.fail("The HW button did not receive the click.");
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   121
        } else {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   122
            MixingInHwPanel.pass();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   123
        }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   124
    }//End  init()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   125
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   126
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   127
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   128
    /*****************************************************
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   129
     * Standard Test Machinery Section
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   130
     * DO NOT modify anything in this section -- it's a
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   131
     * standard chunk of code which has all of the
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   132
     * synchronisation necessary for the test harness.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   133
     * By keeping it the same in all tests, it is easier
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   134
     * to read and understand someone else's test, as
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   135
     * well as insuring that all tests behave correctly
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   136
     * with the test harness.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   137
     * There is a section following this for test-
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   138
     * classes
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   139
     ******************************************************/
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   140
    private static boolean theTestPassed = false;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   141
    private static boolean testGeneratedInterrupt = false;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   142
    private static String failureMessage = "";
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   143
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   144
    private static Thread mainThread = null;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   145
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   146
    private static int sleepTime = 300000;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   147
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   148
    // Not sure about what happens if multiple of this test are
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   149
    //  instantiated in the same VM.  Being static (and using
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   150
    //  static vars), it aint gonna work.  Not worrying about
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   151
    //  it for now.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   152
    public static void main( String args[] ) throws InterruptedException
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   153
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   154
        mainThread = Thread.currentThread();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   155
        try
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   156
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   157
            init();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   158
        }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   159
        catch( TestPassedException e )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   160
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   161
            //The test passed, so just return from main and harness will
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   162
            // interepret this return as a pass
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   163
            return;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   164
        }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   165
        //At this point, neither test pass nor test fail has been
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   166
        // called -- either would have thrown an exception and ended the
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   167
        // test, so we know we have multiple threads.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   168
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   169
        //Test involves other threads, so sleep and wait for them to
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   170
        // called pass() or fail()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   171
        try
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   172
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   173
            Thread.sleep( sleepTime );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   174
            //Timed out, so fail the test
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   175
            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   176
        }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   177
        catch (InterruptedException e)
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   178
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   179
            //The test harness may have interrupted the test.  If so, rethrow the exception
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   180
            // so that the harness gets it and deals with it.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   181
            if( ! testGeneratedInterrupt ) throw e;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   182
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   183
            //reset flag in case hit this code more than once for some reason (just safety)
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   184
            testGeneratedInterrupt = false;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   185
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   186
            if ( theTestPassed == false )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   187
            {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   188
                throw new RuntimeException( failureMessage );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   189
            }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   190
        }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   191
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   192
    }//main
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   193
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   194
    public static synchronized void setTimeoutTo( int seconds )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   195
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   196
        sleepTime = seconds * 1000;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   197
    }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   198
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   199
    public static synchronized void pass()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   200
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   201
        Sysout.println( "The test passed." );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   202
        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   203
        //first check if this is executing in main thread
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   204
        if ( mainThread == Thread.currentThread() )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   205
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   206
            //Still in the main thread, so set the flag just for kicks,
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   207
            // and throw a test passed exception which will be caught
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   208
            // and end the test.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   209
            theTestPassed = true;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   210
            throw new TestPassedException();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   211
        }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   212
        theTestPassed = true;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   213
        testGeneratedInterrupt = true;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   214
        mainThread.interrupt();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   215
    }//pass()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   216
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   217
    public static synchronized void fail()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   218
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   219
        //test writer didn't specify why test failed, so give generic
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   220
        fail( "it just plain failed! :-)" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   221
    }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   222
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   223
    public static synchronized void fail( String whyFailed )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   224
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   225
        Sysout.println( "The test failed: " + whyFailed );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   226
        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   227
        //check if this called from main thread
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   228
        if ( mainThread == Thread.currentThread() )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   229
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   230
            //If main thread, fail now 'cause not sleeping
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   231
            throw new RuntimeException( whyFailed );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   232
        }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   233
        theTestPassed = false;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   234
        testGeneratedInterrupt = true;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   235
        failureMessage = whyFailed;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   236
        mainThread.interrupt();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   237
    }//fail()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   238
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   239
}// class MixingInHwPanel
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   240
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   241
//This exception is used to exit from any level of call nesting
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   242
// when it's determined that the test has passed, and immediately
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   243
// end the test.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   244
class TestPassedException extends RuntimeException
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   245
{
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   246
}
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   247
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   248
//*********** End Standard Test Machinery Section **********
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   249
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   250
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   251
//************ Begin classes defined for the test ****************
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   252
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   253
// if want to make listeners, here is the recommended place for them, then instantiate
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   254
//  them in init()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   255
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   256
/* Example of a class which may be written as part of a test
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   257
class NewClass implements anInterface
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   258
 {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   259
   static int newVar = 0;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   260
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   261
   public void eventDispatched(AWTEvent e)
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   262
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   263
      //Counting events to see if we get enough
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   264
      eventCount++;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   265
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   266
      if( eventCount == 20 )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   267
       {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   268
         //got enough events, so pass
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   269
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   270
         MixingInHwPanel.pass();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   271
       }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   272
      else if( tries == 20 )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   273
       {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   274
         //tried too many times without getting enough events so fail
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   275
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   276
         MixingInHwPanel.fail();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   277
       }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   278
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   279
    }// eventDispatched()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   280
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   281
 }// NewClass class
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   282
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   283
*/
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   284
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   285
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   286
//************** End classes defined for the test *******************
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   287
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   288
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   289
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   290
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   291
/****************************************************
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   292
 Standard Test Machinery
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   293
 DO NOT modify anything below -- it's a standard
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   294
  chunk of code whose purpose is to make user
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   295
  interaction uniform, and thereby make it simpler
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   296
  to read and understand someone else's test.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   297
 ****************************************************/
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   298
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   299
/**
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   300
 This is part of the standard test machinery.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   301
 It creates a dialog (with the instructions), and is the interface
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   302
  for sending text messages to the user.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   303
 To print the instructions, send an array of strings to Sysout.createDialog
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   304
  WithInstructions method.  Put one line of instructions per array entry.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   305
 To display a message for the tester to see, simply call Sysout.println
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   306
  with the string to be displayed.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   307
 This mimics System.out.println but works within the test harness as well
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   308
  as standalone.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   309
 */
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   310
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   311
class Sysout
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   312
{
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   313
    private static TestDialog dialog;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   314
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   315
    public static void createDialogWithInstructions( String[] instructions )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   316
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   317
        dialog = new TestDialog( new Frame(), "Instructions" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   318
        dialog.printInstructions( instructions );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   319
        dialog.setVisible(true);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   320
        println( "Any messages for the tester will display here." );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   321
    }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   322
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   323
    public static void createDialog( )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   324
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   325
        dialog = new TestDialog( new Frame(), "Instructions" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   326
        String[] defInstr = { "Instructions will appear here. ", "" } ;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   327
        dialog.printInstructions( defInstr );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   328
        dialog.setVisible(true);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   329
        println( "Any messages for the tester will display here." );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   330
    }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   331
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   332
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   333
    public static void printInstructions( String[] instructions )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   334
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   335
        dialog.printInstructions( instructions );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   336
    }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   337
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   338
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   339
    public static void println( String messageIn )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   340
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   341
        dialog.displayMessage( messageIn );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   342
        System.out.println(messageIn);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   343
    }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   344
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   345
}// Sysout  class
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   346
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   347
/**
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   348
  This is part of the standard test machinery.  It provides a place for the
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   349
   test instructions to be displayed, and a place for interactive messages
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   350
   to the user to be displayed.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   351
  To have the test instructions displayed, see Sysout.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   352
  To have a message to the user be displayed, see Sysout.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   353
  Do not call anything in this dialog directly.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   354
  */
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   355
class TestDialog extends Dialog
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   356
{
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   357
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   358
    TextArea instructionsText;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   359
    TextArea messageText;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   360
    int maxStringLength = 80;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   361
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   362
    //DO NOT call this directly, go through Sysout
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   363
    public TestDialog( Frame frame, String name )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   364
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   365
        super( frame, name );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   366
        int scrollBoth = TextArea.SCROLLBARS_BOTH;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   367
        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   368
        add( "North", instructionsText );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   369
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   370
        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   371
        add("Center", messageText);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   372
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   373
        pack();
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   374
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   375
        setVisible(true);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   376
    }// TestDialog()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   377
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   378
    //DO NOT call this directly, go through Sysout
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   379
    public void printInstructions( String[] instructions )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   380
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   381
        //Clear out any current instructions
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   382
        instructionsText.setText( "" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   383
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   384
        //Go down array of instruction strings
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   385
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   386
        String printStr, remainingStr;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   387
        for( int i=0; i < instructions.length; i++ )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   388
        {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   389
            //chop up each into pieces maxSringLength long
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   390
            remainingStr = instructions[ i ];
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   391
            while( remainingStr.length() > 0 )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   392
            {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   393
                //if longer than max then chop off first max chars to print
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   394
                if( remainingStr.length() >= maxStringLength )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   395
                {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   396
                    //Try to chop on a word boundary
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   397
                    int posOfSpace = remainingStr.
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   398
                        lastIndexOf( ' ', maxStringLength - 1 );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   399
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   400
                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   401
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   402
                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   403
                    remainingStr = remainingStr.substring( posOfSpace + 1 );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   404
                }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   405
                //else just print
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   406
                else
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   407
                {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   408
                    printStr = remainingStr;
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   409
                    remainingStr = "";
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   410
                }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   411
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   412
                instructionsText.append( printStr + "\n" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   413
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   414
            }// while
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   415
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   416
        }// for
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   417
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   418
    }//printInstructions()
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   419
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   420
    //DO NOT call this directly, go through Sysout
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   421
    public void displayMessage( String messageIn )
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   422
    {
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   423
        messageText.append( messageIn + "\n" );
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   424
        System.out.println(messageIn);
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   425
    }
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   426
63360b4ca6c4 6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff changeset
   427
}// TestDialog  class