13993
|
1 |
/*
|
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
import java.awt.Dimension;
|
|
27 |
import java.awt.Frame;
|
|
28 |
import java.awt.TextArea;
|
|
29 |
import java.awt.Toolkit;
|
|
30 |
|
|
31 |
import sun.awt.SunToolkit;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* @test
|
|
35 |
* @bug 7160627
|
|
36 |
* @summary We shouldn't get different frame size when we call Frame.pack()
|
|
37 |
* twice.
|
|
38 |
* @author Sergey Bylokhov
|
|
39 |
*/
|
|
40 |
public final class TextAreaTwicePack {
|
|
41 |
|
|
42 |
public static void main(final String[] args) {
|
|
43 |
final Frame frame = new Frame();
|
|
44 |
final TextArea ta = new TextArea();
|
|
45 |
frame.add(ta);
|
|
46 |
frame.pack();
|
|
47 |
frame.setVisible(true);
|
|
48 |
sleep();
|
|
49 |
final Dimension before = frame.getSize();
|
|
50 |
frame.pack();
|
|
51 |
final Dimension after = frame.getSize();
|
|
52 |
if (!after.equals(before)) {
|
|
53 |
throw new RuntimeException(
|
|
54 |
"Expected size: " + before + ", actual size: " + after);
|
|
55 |
}
|
|
56 |
frame.dispose();
|
|
57 |
}
|
|
58 |
|
|
59 |
private static void sleep() {
|
|
60 |
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
|
|
61 |
try {
|
|
62 |
Thread.sleep(500L);
|
|
63 |
} catch (InterruptedException ignored) {
|
|
64 |
}
|
|
65 |
}
|
|
66 |
}
|