author | dcubed |
Wed, 20 Jun 2012 14:18:25 -0700 | |
changeset 13092 | 3b4aad065f27 |
parent 7263 | 3da4189127ac |
permissions | -rw-r--r-- |
7263
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
1 |
/* |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
4 |
* |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
8 |
* |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
14 |
* |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
18 |
* |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
21 |
* questions. |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
22 |
*/ |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
23 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
24 |
/* |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
25 |
* @test |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
26 |
* @bug 6981576 |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
27 |
* @summary Tests that default border for the titled border is not null |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
28 |
* @author Sergey Malenkov |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
29 |
*/ |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
30 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
31 |
import java.awt.Component; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
32 |
import java.awt.Graphics; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
33 |
import javax.swing.JFrame; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
34 |
import javax.swing.JPanel; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
35 |
import javax.swing.SwingUtilities; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
36 |
import javax.swing.UIManager; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
37 |
import javax.swing.UIManager.LookAndFeelInfo; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
38 |
import javax.swing.border.TitledBorder; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
39 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
40 |
public class Test6981576 extends TitledBorder implements Runnable, Thread.UncaughtExceptionHandler { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
41 |
public static void main(String[] args) { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
42 |
SwingUtilities.invokeLater(new Test6981576()); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
43 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
44 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
45 |
private int index; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
46 |
private LookAndFeelInfo[] infos; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
47 |
private JFrame frame; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
48 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
49 |
private Test6981576() { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
50 |
super(""); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
51 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
52 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
53 |
@Override |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
54 |
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
55 |
getBorder().paintBorder(c, g, x, y, width, height); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
56 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
57 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
58 |
public void run() { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
59 |
if (this.infos == null) { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
60 |
this.infos = UIManager.getInstalledLookAndFeels(); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
61 |
Thread.currentThread().setUncaughtExceptionHandler(this); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
62 |
JPanel panel = new JPanel(); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
63 |
panel.setBorder(this); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
64 |
this.frame = new JFrame(getClass().getSimpleName()); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
65 |
this.frame.add(panel); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
66 |
this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
67 |
this.frame.setVisible(true); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
68 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
69 |
if (this.index == this.infos.length) { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
70 |
this.frame.dispose(); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
71 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
72 |
else { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
73 |
LookAndFeelInfo info = this.infos[this.index % this.infos.length]; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
74 |
try { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
75 |
UIManager.setLookAndFeel(info.getClassName()); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
76 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
77 |
catch (Exception exception) { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
78 |
System.err.println("could not change look and feel"); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
79 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
80 |
SwingUtilities.updateComponentTreeUI(this.frame); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
81 |
this.frame.pack(); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
82 |
this.frame.setLocationRelativeTo(null); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
83 |
this.index++; |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
84 |
SwingUtilities.invokeLater(this); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
85 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
86 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
87 |
|
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
88 |
public void uncaughtException(Thread thread, Throwable throwable) { |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
89 |
System.exit(1); |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
90 |
} |
3da4189127ac
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
malenkov
parents:
diff
changeset
|
91 |
} |