author | ohair |
Tue, 25 May 2010 15:58:33 -0700 | |
changeset 5506 | 202f599c92aa |
parent 463 | 435cd1cc42b6 |
permissions | -rw-r--r-- |
463
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
463
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
4 |
* |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
8 |
* |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
14 |
* |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
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. |
|
463
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
22 |
*/ |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
23 |
|
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
24 |
/* |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
25 |
* @test |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
26 |
* @bug 6625450 |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
27 |
* @summary Tests the baseline of the titled border |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
28 |
* @author Sergey Malenkov |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
29 |
*/ |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
30 |
|
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
31 |
import java.awt.Component; |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
32 |
import javax.swing.border.TitledBorder; |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
33 |
|
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
34 |
public class Test6625450 { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
35 |
|
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
36 |
public static void main(String[] args) { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
37 |
// test height |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
38 |
test(false, 0, Integer.MAX_VALUE); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
39 |
test(false, 0, 1); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
40 |
test(true, 0, -1); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
41 |
test(true, 0, Integer.MIN_VALUE); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
42 |
// test width |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
43 |
test(false, Integer.MAX_VALUE, 0); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
44 |
test(false, 1, 0); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
45 |
test(true, -1, 0); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
46 |
test(true, Integer.MIN_VALUE, 0); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
47 |
} |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
48 |
|
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
49 |
private static final TitledBorder BORDER = new TitledBorder("123"); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
50 |
private static final Component COMPONENT = new Component() { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
51 |
}; |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
52 |
|
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
53 |
private static void test(boolean expected, int width, int height) { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
54 |
try { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
55 |
BORDER.getBaseline(COMPONENT, width, height); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
56 |
|
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
57 |
if (expected) { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
58 |
throw new Error("expected IllegalArgumentException"); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
59 |
} |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
60 |
} |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
61 |
catch (IllegalArgumentException exception) { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
62 |
if (!expected) { |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
63 |
throw new Error("unexpected exception", exception); |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
64 |
} |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
65 |
} |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
66 |
} |
435cd1cc42b6
6625450: javax.swing.border.TitledBorder.getBaseline() doesn't throw IAE when width is < 0
malenkov
parents:
diff
changeset
|
67 |
} |