author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 35989 | ca0acbb82ed9 |
permissions | -rw-r--r-- |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
1 |
|
35989
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
2 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
3 |
* Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. |
35989
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
5 |
* |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
9 |
* |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
14 |
* accompanied this code). |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
15 |
* |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
19 |
* |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
22 |
* questions. |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
23 |
*/ |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
24 |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
25 |
/* |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
26 |
* @test |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
27 |
* @key headful |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
28 |
* @bug 8139581 |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
29 |
* @summary AWT components are not drawn after removal and addition to a container |
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35989
diff
changeset
|
30 |
* @author Anton Litvinov |
35989
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
31 |
*/ |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
32 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
33 |
import java.awt.Button; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
34 |
import java.awt.Color; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
35 |
import java.awt.Canvas; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
36 |
import java.awt.Frame; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
37 |
import java.awt.Graphics; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
38 |
import java.awt.Panel; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
39 |
import java.util.ArrayList; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
40 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
41 |
public class ComponentIsNotDrawnAfterRemoveAddTest { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
42 |
private final Frame frame; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
43 |
private final Panel panel; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
44 |
private final ArrayList<Testable> compList = new ArrayList<Testable>(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
45 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
46 |
public ComponentIsNotDrawnAfterRemoveAddTest() { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
47 |
frame = new Frame("ComponentIsNotDrawnAfterRemoveAddTest"); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
48 |
frame.setSize(500, 500); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
49 |
frame.setLocation(200, 200); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
50 |
frame.setLayout(null); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
51 |
frame.setBackground(Color.RED); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
52 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
53 |
panel = new Panel(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
54 |
panel.setLayout(null); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
55 |
panel.setBounds(25, 100, 455, 295); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
56 |
panel.setBackground(Color.GREEN); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
57 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
58 |
for (int i = 0; i < 10; i++) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
59 |
TestCanvas canv1 = new TestCanvas(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
60 |
canv1.setBounds(i * 45 + 5, 15, 30 + i, 30 + i); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
61 |
panel.add(canv1); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
62 |
compList.add(canv1); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
63 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
64 |
TestButton btn1 = new TestButton(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
65 |
btn1.setBounds(i * 45 + 5, 60, 30 + i, 30 + i); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
66 |
panel.add(btn1); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
67 |
compList.add(btn1); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
68 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
69 |
TestCanvas canv2 = new TestCanvas(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
70 |
canv2.setBounds(i * 45 + 5, 105, 30 + i, 30 + i); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
71 |
panel.add(canv2); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
72 |
compList.add(canv2); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
73 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
74 |
TestButton btn2 = new TestButton(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
75 |
btn2.setBounds(i * 45 + 5, 150, 30 + i, 30 + i); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
76 |
panel.add(btn2); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
77 |
compList.add(btn2); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
78 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
79 |
TestCanvas canv3 = new TestCanvas(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
80 |
canv3.setBounds(i * 45 + 5, 195, 30 + i, 30 + i); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
81 |
panel.add(canv3); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
82 |
compList.add(canv3); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
83 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
84 |
TestButton btn3 = new TestButton(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
85 |
btn3.setBounds(i * 45 + 5, 240, 30 + i, 30 + i); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
86 |
panel.add(btn3); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
87 |
compList.add(btn3); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
88 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
89 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
90 |
frame.add(panel); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
91 |
frame.setVisible(true); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
92 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
93 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
94 |
private void runTest() { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
95 |
try { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
96 |
doSleep(1500); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
97 |
checkTestableComponents(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
98 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
99 |
for (int i = 0; i < 5; i++) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
100 |
System.err.println(String.format("Test iteration #%d:", i)); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
101 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
102 |
frame.remove(panel); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
103 |
frame.invalidate(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
104 |
frame.validate(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
105 |
frame.add(panel); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
106 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
107 |
doSleep(1500); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
108 |
checkTestableComponents(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
109 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
110 |
} finally { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
111 |
frame.dispose(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
112 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
113 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
114 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
115 |
private void doSleep(long millis) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
116 |
try { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
117 |
Thread.sleep(millis); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
118 |
} catch (InterruptedException ie) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
119 |
ie.printStackTrace(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
120 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
121 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
122 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
123 |
private void checkTestableComponents() throws RuntimeException { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
124 |
int notDrawnCompsCount = 0; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
125 |
for (Testable comp : compList) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
126 |
if (!comp.wasPaintCalled()) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
127 |
notDrawnCompsCount++; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
128 |
} else { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
129 |
comp.resetPaintCalledFlag(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
130 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
131 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
132 |
if (notDrawnCompsCount > 0) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
133 |
throw new RuntimeException(String.format( |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
134 |
"'paint' method of %d components was not called.", notDrawnCompsCount)); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
135 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
136 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
137 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
138 |
private interface Testable { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
139 |
boolean wasPaintCalled(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
140 |
void resetPaintCalledFlag(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
141 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
142 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
143 |
private static class TestCanvas extends Canvas implements Testable { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
144 |
private volatile boolean paintWasCalled = false; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
145 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
146 |
@Override |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
147 |
public void paint(Graphics g) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
148 |
paintWasCalled = true; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
149 |
super.paint(g); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
150 |
g.setColor(Color.BLUE); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
151 |
g.fillRect(0, 0, getWidth(), getHeight()); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
152 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
153 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
154 |
@Override |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
155 |
public boolean wasPaintCalled() { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
156 |
return paintWasCalled; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
157 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
158 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
159 |
@Override |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
160 |
public void resetPaintCalledFlag() { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
161 |
paintWasCalled = false; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
162 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
163 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
164 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
165 |
private static class TestButton extends Button implements Testable { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
166 |
private volatile boolean paintWasCalled = false; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
167 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
168 |
@Override |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
169 |
public void paint(Graphics g) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
170 |
paintWasCalled = true; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
171 |
super.paint(g); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
172 |
g.setColor(Color.YELLOW); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
173 |
g.fillRect(0, 0, 15, 15); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
174 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
175 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
176 |
@Override |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
177 |
public boolean wasPaintCalled() { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
178 |
return paintWasCalled; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
179 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
180 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
181 |
@Override |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
182 |
public void resetPaintCalledFlag() { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
183 |
paintWasCalled = false; |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
184 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
185 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
186 |
|
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
187 |
public static void main(String[] args) { |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
188 |
new ComponentIsNotDrawnAfterRemoveAddTest().runTest(); |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
189 |
} |
ca0acbb82ed9
8139581: AWT components are not drawn after removal and addition to a container
alitvinov
parents:
diff
changeset
|
190 |
} |