author | ohair |
Thu, 09 Sep 2010 16:29:40 -0700 (2010-09-09) | |
changeset 6387 | 035df75cc1a9 |
parent 5506 | 202f599c92aa |
child 18121 | f2eb5e324296 |
permissions | -rw-r--r-- |
2644
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2009, 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 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
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 |
/* |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
25 |
@test %W% %E% |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
26 |
@bug 6829858 |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
27 |
@summary Mixing should work inside heavyweight containers |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
28 |
@author anthony.petrov@sun.com: area=awt.mixing |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
29 |
@library ../regtesthelpers |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
30 |
@build Util |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
31 |
@run main MixingInHwPanel |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
32 |
*/ |
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 |
* MixingInHwPanel.java |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
37 |
* |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
38 |
* summary: Mixing should work inside heavyweight containers |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
39 |
*/ |
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 |
import java.awt.*; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
42 |
import java.awt.event.*; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
43 |
import javax.swing.*; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
44 |
import test.java.awt.regtesthelpers.Util; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
45 |
|
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 |
public class MixingInHwPanel |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
49 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
50 |
static volatile boolean failed = true; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
51 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
52 |
private static void init() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
53 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
54 |
//*** Create instructions for the user here *** |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
55 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
56 |
String[] instructions = |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
57 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
58 |
"This is an AUTOMATIC test, simply wait until it is done.", |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
59 |
"The result (passed or failed) will be shown in the", |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
60 |
"message window below." |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
61 |
}; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
62 |
Sysout.createDialog( ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
63 |
Sysout.printInstructions( instructions ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
64 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
65 |
// Create the components: frame -> hwPanel -> JDesktopPane -> |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
66 |
// -> JInternalFrame -> hwButton |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
67 |
Frame frame = new Frame("Mixing in a heavyweight Panel"); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
68 |
frame.setBounds(100, 100, 640, 480); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
69 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
70 |
Panel hwPanel = new Panel(new BorderLayout()); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
71 |
frame.add(hwPanel); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
72 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
73 |
JDesktopPane desktop = new JDesktopPane(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
74 |
hwPanel.add(desktop); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
75 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
76 |
JInternalFrame iFrame = new JInternalFrame("one", |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
77 |
true, true, true, true); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
78 |
iFrame.setPreferredSize(new Dimension(150, 55)); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
79 |
iFrame.setBounds(600, 100, 150, 55); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
80 |
iFrame.setVisible(true); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
81 |
desktop.add(iFrame); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
82 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
83 |
Button button = new Button("HW Button"); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
84 |
button.addActionListener(new ActionListener() { |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
85 |
public void actionPerformed(ActionEvent e) { |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
86 |
failed = false; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
87 |
} |
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 |
iFrame.add(button); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
90 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
91 |
// Show the frame with the hwButton slightly hidden initially |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
92 |
frame.setVisible(true); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
93 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
94 |
Robot robot = Util.createRobot(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
95 |
robot.setAutoDelay(20); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
96 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
97 |
Util.waitForIdle(robot); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
98 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
99 |
// Now resize the frame so that the button is fully visible |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
100 |
frame.setBounds(100, 100, 800, 480); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
101 |
frame.validate(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
102 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
103 |
Util.waitForIdle(robot); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
104 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
105 |
// 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
|
106 |
Point bLoc = button.getLocationOnScreen(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
107 |
robot.mouseMove(bLoc.x + button.getWidth() - 6, bLoc.y + button.getHeight() / 2); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
108 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
109 |
Util.waitForIdle(robot); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
110 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
111 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
112 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
113 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
114 |
Util.waitForIdle(robot); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
115 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
116 |
// 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
|
117 |
// listener will make failed == false. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
118 |
if (failed) { |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
119 |
MixingInHwPanel.fail("The HW button did not receive the click."); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
120 |
} else { |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
121 |
MixingInHwPanel.pass(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
122 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
123 |
}//End init() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
124 |
|
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 |
* Standard Test Machinery Section |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
129 |
* DO NOT modify anything in this section -- it's a |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
130 |
* standard chunk of code which has all of the |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
131 |
* synchronisation necessary for the test harness. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
132 |
* By keeping it the same in all tests, it is easier |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
133 |
* to read and understand someone else's test, as |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
134 |
* well as insuring that all tests behave correctly |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
135 |
* with the test harness. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
136 |
* There is a section following this for test- |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
137 |
* classes |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
138 |
******************************************************/ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
139 |
private static boolean theTestPassed = false; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
140 |
private static boolean testGeneratedInterrupt = false; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
141 |
private static String failureMessage = ""; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
142 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
143 |
private static Thread mainThread = null; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
144 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
145 |
private static int sleepTime = 300000; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
146 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
147 |
// Not sure about what happens if multiple of this test are |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
148 |
// instantiated in the same VM. Being static (and using |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
149 |
// static vars), it aint gonna work. Not worrying about |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
150 |
// it for now. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
151 |
public static void main( String args[] ) throws InterruptedException |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
152 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
153 |
mainThread = Thread.currentThread(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
154 |
try |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
155 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
156 |
init(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
157 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
158 |
catch( TestPassedException e ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
159 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
160 |
//The test passed, so just return from main and harness will |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
161 |
// interepret this return as a pass |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
162 |
return; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
163 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
164 |
//At this point, neither test pass nor test fail has been |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
165 |
// called -- either would have thrown an exception and ended the |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
166 |
// test, so we know we have multiple threads. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
167 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
168 |
//Test involves other threads, so sleep and wait for them to |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
169 |
// called pass() or fail() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
170 |
try |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
171 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
172 |
Thread.sleep( sleepTime ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
173 |
//Timed out, so fail the test |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
174 |
throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
175 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
176 |
catch (InterruptedException e) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
177 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
178 |
//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
|
179 |
// so that the harness gets it and deals with it. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
180 |
if( ! testGeneratedInterrupt ) throw e; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
181 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
182 |
//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
|
183 |
testGeneratedInterrupt = false; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
184 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
185 |
if ( theTestPassed == false ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
186 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
187 |
throw new RuntimeException( failureMessage ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
188 |
} |
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 |
}//main |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
192 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
193 |
public static synchronized void setTimeoutTo( int seconds ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
194 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
195 |
sleepTime = seconds * 1000; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
196 |
} |
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 |
public static synchronized void pass() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
199 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
200 |
Sysout.println( "The test passed." ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
201 |
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
|
202 |
//first check if this is executing in main thread |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
203 |
if ( mainThread == Thread.currentThread() ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
204 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
205 |
//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
|
206 |
// and throw a test passed exception which will be caught |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
207 |
// and end the test. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
208 |
theTestPassed = true; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
209 |
throw new TestPassedException(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
210 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
211 |
theTestPassed = true; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
212 |
testGeneratedInterrupt = true; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
213 |
mainThread.interrupt(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
214 |
}//pass() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
215 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
216 |
public static synchronized void fail() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
217 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
218 |
//test writer didn't specify why test failed, so give generic |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
219 |
fail( "it just plain failed! :-)" ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
220 |
} |
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 |
public static synchronized void fail( String whyFailed ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
223 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
224 |
Sysout.println( "The test failed: " + whyFailed ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
225 |
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
|
226 |
//check if this called from main thread |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
227 |
if ( mainThread == Thread.currentThread() ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
228 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
229 |
//If main thread, fail now 'cause not sleeping |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
230 |
throw new RuntimeException( whyFailed ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
231 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
232 |
theTestPassed = false; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
233 |
testGeneratedInterrupt = true; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
234 |
failureMessage = whyFailed; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
235 |
mainThread.interrupt(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
236 |
}//fail() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
237 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
238 |
}// class MixingInHwPanel |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
239 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
240 |
//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
|
241 |
// when it's determined that the test has passed, and immediately |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
242 |
// end the test. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
243 |
class TestPassedException extends RuntimeException |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
244 |
{ |
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 |
//*********** End Standard Test Machinery Section ********** |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
248 |
|
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 |
//************ Begin classes defined for the test **************** |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
251 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
252 |
// 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
|
253 |
// them in init() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
254 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
255 |
/* 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
|
256 |
class NewClass implements anInterface |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
257 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
258 |
static int newVar = 0; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
259 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
260 |
public void eventDispatched(AWTEvent e) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
261 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
262 |
//Counting events to see if we get enough |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
263 |
eventCount++; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
264 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
265 |
if( eventCount == 20 ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
266 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
267 |
//got enough events, so pass |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
268 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
269 |
MixingInHwPanel.pass(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
270 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
271 |
else if( tries == 20 ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
272 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
273 |
//tried too many times without getting enough events so fail |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
274 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
275 |
MixingInHwPanel.fail(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
276 |
} |
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 |
}// eventDispatched() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
279 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
280 |
}// NewClass class |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
281 |
|
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 |
//************** End classes defined for the test ******************* |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
286 |
|
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 |
Standard Test Machinery |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
292 |
DO NOT modify anything below -- it's a standard |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
293 |
chunk of code whose purpose is to make user |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
294 |
interaction uniform, and thereby make it simpler |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
295 |
to read and understand someone else's test. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
296 |
****************************************************/ |
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 |
This is part of the standard test machinery. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
300 |
It creates a dialog (with the instructions), and is the interface |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
301 |
for sending text messages to the user. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
302 |
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
|
303 |
WithInstructions method. Put one line of instructions per array entry. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
304 |
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
|
305 |
with the string to be displayed. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
306 |
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
|
307 |
as standalone. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
308 |
*/ |
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 |
class Sysout |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
311 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
312 |
private static TestDialog dialog; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
313 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
314 |
public static void createDialogWithInstructions( String[] instructions ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
315 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
316 |
dialog = new TestDialog( new Frame(), "Instructions" ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
317 |
dialog.printInstructions( instructions ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
318 |
dialog.setVisible(true); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
319 |
println( "Any messages for the tester will display here." ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
320 |
} |
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 |
public static void createDialog( ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
323 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
324 |
dialog = new TestDialog( new Frame(), "Instructions" ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
325 |
String[] defInstr = { "Instructions will appear here. ", "" } ; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
326 |
dialog.printInstructions( defInstr ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
327 |
dialog.setVisible(true); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
328 |
println( "Any messages for the tester will display here." ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
329 |
} |
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 |
public static void printInstructions( String[] instructions ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
333 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
334 |
dialog.printInstructions( instructions ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
335 |
} |
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 |
public static void println( String messageIn ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
339 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
340 |
dialog.displayMessage( messageIn ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
341 |
System.out.println(messageIn); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
342 |
} |
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 |
}// Sysout class |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
345 |
|
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 |
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
|
348 |
test instructions to be displayed, and a place for interactive messages |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
349 |
to the user to be displayed. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
350 |
To have the test instructions displayed, see Sysout. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
351 |
To have a message to the user be displayed, see Sysout. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
352 |
Do not call anything in this dialog directly. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
353 |
*/ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
354 |
class TestDialog extends Dialog |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
355 |
{ |
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 |
TextArea instructionsText; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
358 |
TextArea messageText; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
359 |
int maxStringLength = 80; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
360 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
361 |
//DO NOT call this directly, go through Sysout |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
362 |
public TestDialog( Frame frame, String name ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
363 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
364 |
super( frame, name ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
365 |
int scrollBoth = TextArea.SCROLLBARS_BOTH; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
366 |
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
367 |
add( "North", instructionsText ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
368 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
369 |
messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
370 |
add("Center", messageText); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
371 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
372 |
pack(); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
373 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
374 |
setVisible(true); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
375 |
}// TestDialog() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
376 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
377 |
//DO NOT call this directly, go through Sysout |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
378 |
public void printInstructions( String[] instructions ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
379 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
380 |
//Clear out any current instructions |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
381 |
instructionsText.setText( "" ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
382 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
383 |
//Go down array of instruction strings |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
384 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
385 |
String printStr, remainingStr; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
386 |
for( int i=0; i < instructions.length; i++ ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
387 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
388 |
//chop up each into pieces maxSringLength long |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
389 |
remainingStr = instructions[ i ]; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
390 |
while( remainingStr.length() > 0 ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
391 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
392 |
//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
|
393 |
if( remainingStr.length() >= maxStringLength ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
394 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
395 |
//Try to chop on a word boundary |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
396 |
int posOfSpace = remainingStr. |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
397 |
lastIndexOf( ' ', maxStringLength - 1 ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
398 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
399 |
if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
400 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
401 |
printStr = remainingStr.substring( 0, posOfSpace + 1 ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
402 |
remainingStr = remainingStr.substring( posOfSpace + 1 ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
403 |
} |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
404 |
//else just print |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
405 |
else |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
406 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
407 |
printStr = remainingStr; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
408 |
remainingStr = ""; |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
409 |
} |
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 |
instructionsText.append( printStr + "\n" ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
412 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
413 |
}// while |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
414 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
415 |
}// for |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
416 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
417 |
}//printInstructions() |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
418 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
419 |
//DO NOT call this directly, go through Sysout |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
420 |
public void displayMessage( String messageIn ) |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
421 |
{ |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
422 |
messageText.append( messageIn + "\n" ); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
423 |
System.out.println(messageIn); |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
424 |
} |
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 |
}// TestDialog class |
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
427 |
|
63360b4ca6c4
6829858: JInternalFrame is not redrawing heavyweight children properly
anthony
parents:
diff
changeset
|
428 |