jdk/test/java/awt/Frame/FrameStateTest/FrameStateTest.java
author amurillo
Wed, 15 Aug 2012 16:49:38 -0700
changeset 13465 d3fc5d192448
parent 12525 93404c8fc9e6
permissions -rw-r--r--
7191765: make jdk8 the default jprt release for hs24 Reviewed-by: jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12525
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     1
/*
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     4
 *
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     7
 * published by the Free Software Foundation.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     8
 *
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    13
 * accompanied this code).
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    14
 *
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    18
 *
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    21
 * questions.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    22
 */
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    23
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    24
/*
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    25
  test
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    26
  @bug 4157271
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    27
  @summary Checks that when a Frame is created it honors the state it
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    28
        was set to. The bug was that if setState(Frame.ICONIFIED) was
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    29
        called before setVisible(true) the Frame would be shown in NORMAL
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    30
        state instead of ICONIFIED.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    31
  @author JTG East Team: area=awt.Frame
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    32
  @run applet/manual=yesno FrameStateTest.html
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    33
*/
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    34
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    35
/**
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    36
 * FrameStateTest.java
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    37
 *
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    38
 * summary: Checks that when setState(Frame.ICONIFIED) is called before
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    39
 *      setVisible(true) the Frame is shown in the proper iconified state.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    40
 *      The problem was that it did not honor the initial iconic state, but
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    41
 *      instead was shown in the NORMAL state.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    42
 */
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    43
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    44
import java.awt.event.*;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    45
import java.awt.*;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    46
import java.lang.*;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    47
import java.applet.Applet;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    48
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    49
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    50
public class FrameStateTest extends Applet implements ActionListener, ItemListener{
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    51
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    52
   Button btnCreate = new Button("Create Frame");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    53
   Button btnDispose = new Button("Dispose Frame");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    54
   CheckboxGroup cbgState = new CheckboxGroup();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    55
   CheckboxGroup cbgResize = new CheckboxGroup();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    56
   Checkbox cbIconState = new Checkbox("Frame state ICONIFIED",cbgState,false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    57
   Checkbox cbNormState = new Checkbox("Frame state NORMAL",cbgState,true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    58
   Checkbox cbNonResize = new Checkbox("Frame Nonresizable",cbgResize,false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    59
   Checkbox cbResize = new Checkbox("Frame Resizable",cbgResize,true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    60
   int iState = 0;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    61
   boolean bResize = true;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    62
   CreateFrame icontst;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    63
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    64
   public void init() {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    65
      this.setLayout (new BorderLayout ());
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    66
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    67
      String[] instructions =
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    68
       {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    69
        "Steps to try to reproduce this problem:",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    70
        "When this test is run an Applet Viewer window will display. In the",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    71
        "Applet Viewer window select the different options for the Frame (i.e.",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    72
        "{Normal, Non-resizalbe}, {Normal, Resizable}, {Iconified, Resizable},",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    73
        "{Iconified, Non-resizalbe}). After chosing the Frame's state click the",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    74
        "Create Frame button. After the Frame (Frame State Test (Window2)) comes",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    75
        "up make sure the proper behavior occurred (Frame shown in proper state).",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    76
        "Click the Dispose button to close the Frame. Do the above steps for all",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    77
        "the different Frame state combinations available. If you observe the",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    78
        "proper behavior the test has passed, Press the Pass button. Otherwise",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    79
        "the test has failed, Press the Fail button.",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    80
        "Note: In Frame State Test (Window2) you can also chose the different",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    81
        "buttons to see different Frame behavior. An example of a problem that",
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    82
        "has been seen, With the Frame nonresizable you can not iconify the Frame."
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    83
       };
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    84
      Sysout.createDialogWithInstructions( instructions );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    85
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    86
      btnDispose.setEnabled(false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    87
      add(btnCreate, BorderLayout.NORTH);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    88
      add(btnDispose, BorderLayout.SOUTH);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    89
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    90
      Panel p = new Panel(new GridLayout(0,1));
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    91
      p.add(cbIconState);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    92
      p.add(cbResize);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    93
      add(p, BorderLayout.WEST);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    94
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    95
      p = new Panel(new GridLayout(0,1));
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    96
      p.add(cbNormState);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    97
      p.add(cbNonResize);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    98
      add(p, BorderLayout.EAST);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
    99
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   100
      // Add Listeners
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   101
      btnDispose.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   102
      btnCreate.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   103
      cbNormState.addItemListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   104
      cbResize.addItemListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   105
      cbIconState.addItemListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   106
      cbNonResize.addItemListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   107
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   108
      resize(600, 200);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   109
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   110
   }//End  init()
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   111
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   112
   public void actionPerformed(ActionEvent evt) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   113
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   114
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   115
        if (evt.getSource() == btnCreate) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   116
            btnCreate.setEnabled(false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   117
            btnDispose.setEnabled(true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   118
            icontst = new CreateFrame(iState, bResize);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   119
            icontst.show();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   120
        } else if (evt.getSource() == btnDispose) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   121
            btnCreate.setEnabled(true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   122
            btnDispose.setEnabled(false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   123
            icontst.dispose();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   124
        }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   125
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   126
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   127
    public void itemStateChanged(ItemEvent evt) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   128
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   129
        if (cbNormState.getState()) iState = 0;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   130
        if (cbIconState.getState()) iState = 1;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   131
        if (cbResize.getState()) bResize = true;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   132
        if (cbNonResize.getState()) bResize = false;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   133
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   134
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   135
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   136
}// class FrameStateTest
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   137
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   138
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   139
class CreateFrame extends Frame implements ActionListener , WindowListener {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   140
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   141
  static int e=0;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   142
  static int u=0;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   143
  static int p=0;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   144
  static int i=0;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   145
  static int v=0;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   146
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   147
  Button b1, b2, b3, b4, b5, b6, b7;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   148
  boolean resizable = true;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   149
  boolean iconic = false;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   150
  String name = "Frame State Test";
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   151
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   152
  CreateFrame (int iFrameState, boolean bFrameResizable) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   153
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   154
    setTitle("Frame State Test (Window 2)");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   155
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   156
    if (iFrameState == 1) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   157
        iconic = true;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   158
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   159
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   160
    if (!(bFrameResizable)) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   161
        resizable = false;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   162
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   163
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   164
    System.out.println("CREATING FRAME - Initially "+
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   165
        ((iconic) ? "ICONIFIED" : "NORMAL (NON-ICONIFIED)") + " and " +
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   166
        ((resizable) ? "RESIZABLE" : "NON-RESIZABLE") );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   167
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   168
    Sysout.println("CREATING FRAME - Initially "+
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   169
        ((iconic) ? "ICONIFIED" : "NORMAL (NON-ICONIFIED)") + " and " +
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   170
        ((resizable) ? "RESIZABLE" : "NON-RESIZABLE") );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   171
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   172
    setLayout(new FlowLayout() );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   173
    b1 = new Button("resizable");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   174
    add(b1);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   175
    b2 = new Button("resize");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   176
    add(b2);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   177
    b3 = new Button("iconify");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   178
    add(b3);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   179
    b4 = new Button("iconify and restore");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   180
    add(b4);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   181
    b5 = new Button("hide and show");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   182
    add(b5);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   183
    b6 = new Button("hide, iconify and show");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   184
    add(b6);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   185
    b7 = new Button("hide, iconify, show, and restore");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   186
    add(b7);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   187
    b1.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   188
    b2.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   189
    b3.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   190
    b4.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   191
    b5.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   192
    b6.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   193
    b7.addActionListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   194
    addWindowListener(this);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   195
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   196
    setBounds(100,2,200, 200);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   197
    setState(iconic ? Frame.ICONIFIED: Frame.NORMAL);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   198
    setResizable(resizable);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   199
    pack();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   200
    setVisible(true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   201
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   202
  }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   203
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   204
  public void actionPerformed ( ActionEvent e )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   205
  {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   206
    if ( e.getSource() == b2 ) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   207
        Rectangle r = this.getBounds();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   208
        r.width += 10;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   209
        System.out.println(" - button pressed - setting bounds on Frame to: "+r);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   210
        setBounds(r);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   211
        validate();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   212
    } else if ( e.getSource() == b1 ) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   213
        resizable = !resizable;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   214
        System.out.println(" - button pressed - setting Resizable to: "+resizable);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   215
        ((Frame)(b1.getParent())).setResizable(resizable);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   216
    } else if ( e.getSource() == b3 ) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   217
        System.out.println(" - button pressed - setting Iconic: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   218
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   219
        ((Frame)(b1.getParent())).setState(Frame.ICONIFIED);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   220
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   221
    } else if ( e.getSource() == b4 ) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   222
        System.out.println(" - button pressed - setting Iconic: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   223
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   224
        ((Frame)(b1.getParent())).setState(Frame.ICONIFIED);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   225
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   226
        try {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   227
                Thread.sleep(1000);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   228
        } catch (Exception ex) {};
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   229
        System.out.println(" - now restoring: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   230
        ((Frame)(b1.getParent())).setState(Frame.NORMAL);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   231
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   232
    } else if ( e.getSource() == b5 ) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   233
        System.out.println(" - button pressed - hiding : ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   234
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   235
        ((Frame)(b1.getParent())).setVisible(false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   236
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   237
        try {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   238
                Thread.sleep(1000);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   239
        } catch (Exception ex) {};
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   240
        System.out.println(" - now reshowing: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   241
        ((Frame)(b1.getParent())).setVisible(true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   242
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   243
    } else if ( e.getSource() == b6 ) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   244
        System.out.println(" - button pressed - hiding : ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   245
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   246
        ((Frame)(b1.getParent())).setVisible(false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   247
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   248
        try {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   249
                Thread.sleep(1000);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   250
        } catch (Exception ex) {};
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   251
        System.out.println(" - setting Iconic: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   252
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   253
        ((Frame)(b1.getParent())).setState(Frame.ICONIFIED);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   254
        try {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   255
                Thread.sleep(1000);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   256
        } catch (Exception ex) {};
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   257
        System.out.println(" - now reshowing: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   258
        ((Frame)(b1.getParent())).setVisible(true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   259
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   260
    } else if ( e.getSource() == b7 ) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   261
        System.out.println(" - button pressed - hiding : ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   262
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   263
        ((Frame)(b1.getParent())).setVisible(false);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   264
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   265
        try {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   266
                Thread.sleep(1000);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   267
        } catch (Exception ex) {};
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   268
        System.out.println(" - setting Iconic: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   269
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   270
        ((Frame)(b1.getParent())).setState(Frame.ICONIFIED);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   271
        try {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   272
                Thread.sleep(1000);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   273
        } catch (Exception ex) {};
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   274
        System.out.println(" - now reshowing: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   275
        ((Frame)(b1.getParent())).setVisible(true);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   276
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   277
        try {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   278
                Thread.sleep(1000);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   279
        } catch (Exception ex) {};
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   280
        System.out.println(" - now restoring: ");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   281
        ((Frame)(b1.getParent())).setState(Frame.NORMAL);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   282
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   283
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   284
  }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   285
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   286
    public void windowActivated(WindowEvent e) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   287
        System.out.println(name + " Activated");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   288
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   289
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   290
    public void windowClosed(WindowEvent e) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   291
        System.out.println(name + " Closed");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   292
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   293
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   294
    public void windowClosing(WindowEvent e) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   295
        ((Window)(e.getSource())).dispose();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   296
        System.out.println(name + " Closing");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   297
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   298
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   299
    public void windowDeactivated(WindowEvent e) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   300
        System.out.println(name + " Deactivated");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   301
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   302
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   303
    public void windowDeiconified(WindowEvent e) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   304
        System.out.println(name + " Deiconified");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   305
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   306
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   307
    public void windowIconified(WindowEvent e) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   308
        System.out.println(name + " Iconified");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   309
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   310
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   311
    public void windowOpened(WindowEvent e) {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   312
        System.out.println(name + " Opened");
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   313
        dolog();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   314
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   315
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   316
    public void dolog() {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   317
        System.out.println(" getState returns: "+getState());
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   318
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   319
}
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   320
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   321
// }// class FrameStateTest
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   322
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   323
/****************************************************
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   324
 Standard Test Machinery
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   325
 DO NOT modify anything below -- it's a standard
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   326
  chunk of code whose purpose is to make user
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   327
  interaction uniform, and thereby make it simpler
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   328
  to read and understand someone else's test.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   329
 ****************************************************/
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   330
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   331
/**
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   332
 This is part of the standard test machinery.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   333
 It creates a dialog (with the instructions), and is the interface
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   334
  for sending text messages to the user.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   335
 To print the instructions, send an array of strings to Sysout.createDialog
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   336
  WithInstructions method.  Put one line of instructions per array entry.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   337
 To display a message for the tester to see, simply call Sysout.println
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   338
  with the string to be displayed.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   339
 This mimics System.out.println but works within the test harness as well
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   340
  as standalone.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   341
 */
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   342
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   343
class Sysout
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   344
 {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   345
   private static TestDialog dialog;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   346
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   347
   public static void createDialogWithInstructions( String[] instructions )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   348
    {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   349
      dialog = new TestDialog( new Frame(), "Instructions" );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   350
      dialog.printInstructions( instructions );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   351
      dialog.show();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   352
      println( "Any messages for the tester will display here." );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   353
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   354
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   355
   public static void createDialog( )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   356
    {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   357
      dialog = new TestDialog( new Frame(), "Instructions" );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   358
      String[] defInstr = { "Instructions will appear here. ", "" } ;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   359
      dialog.printInstructions( defInstr );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   360
      dialog.show();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   361
      println( "Any messages for the tester will display here." );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   362
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   363
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   364
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   365
   public static void printInstructions( String[] instructions )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   366
    {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   367
      dialog.printInstructions( instructions );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   368
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   369
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   370
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   371
   public static void println( String messageIn )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   372
    {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   373
      dialog.displayMessage( messageIn );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   374
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   375
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   376
 }// Sysout  class
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   377
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   378
/**
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   379
  This is part of the standard test machinery.  It provides a place for the
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   380
   test instructions to be displayed, and a place for interactive messages
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   381
   to the user to be displayed.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   382
  To have the test instructions displayed, see Sysout.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   383
  To have a message to the user be displayed, see Sysout.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   384
  Do not call anything in this dialog directly.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   385
  */
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   386
class TestDialog extends Dialog
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   387
 {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   388
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   389
   TextArea instructionsText;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   390
   TextArea messageText;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   391
   int maxStringLength = 80;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   392
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   393
   //DO NOT call this directly, go through Sysout
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   394
   public TestDialog( Frame frame, String name )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   395
    {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   396
      super( frame, name );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   397
      int scrollBoth = TextArea.SCROLLBARS_BOTH;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   398
      int scrollNone = TextArea.SCROLLBARS_NONE;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   399
      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   400
      add( "North", instructionsText );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   401
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   402
      messageText = new TextArea( "", 10, maxStringLength, scrollBoth );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   403
      add("South", messageText);
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   404
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   405
      pack();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   406
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   407
      show();
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   408
    }// TestDialog()
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   409
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   410
   //DO NOT call this directly, go through Sysout
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   411
   public void printInstructions( String[] instructions )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   412
    {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   413
      //Clear out any current instructions
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   414
      instructionsText.setText( "" );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   415
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   416
      //Go down array of instruction strings
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   417
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   418
      String printStr, remainingStr;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   419
      for( int i=0; i < instructions.length; i++ )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   420
       {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   421
         //chop up each into pieces maxSringLength long
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   422
         remainingStr = instructions[ i ];
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   423
         while( remainingStr.length() > 0 )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   424
          {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   425
            //if longer than max then chop off first max chars to print
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   426
            if( remainingStr.length() >= maxStringLength )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   427
             {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   428
               //Try to chop on a word boundary
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   429
               int posOfSpace = remainingStr.
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   430
                  lastIndexOf( ' ', maxStringLength - 1 );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   431
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   432
               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   433
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   434
               printStr = remainingStr.substring( 0, posOfSpace + 1 );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   435
               remainingStr = remainingStr.substring( posOfSpace + 1 );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   436
             }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   437
            //else just print
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   438
            else
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   439
             {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   440
               printStr = remainingStr;
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   441
               remainingStr = "";
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   442
             }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   443
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   444
            instructionsText.append( printStr + "\n" );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   445
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   446
          }// while
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   447
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   448
       }// for
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   449
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   450
    }//printInstructions()
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   451
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   452
   //DO NOT call this directly, go through Sysout
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   453
   public void displayMessage( String messageIn )
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   454
    {
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   455
      messageText.append( messageIn + "\n" );
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   456
    }
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   457
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   458
93404c8fc9e6 7150109: [macosx] the Frame showed incomplete.
anthony
parents:
diff changeset
   459
 }// TestDialog  class