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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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.
22 */
23
24 /* @test
25 @bug 4960629 7124238
26 @summary Tests if font for html text on widgets in correct.
27 @author Denis Sharypov
28 @run main bug4960629
29 */
30
31 import java.awt.Font;
32 import java.lang.reflect.InvocationTargetException;
33 import javax.swing.JFrame;
34 import javax.swing.JLabel;
35 import javax.swing.SwingUtilities;
36 import javax.swing.UIManager;
37 import javax.swing.plaf.basic.BasicHTML;
38 import javax.swing.text.AttributeSet;
39 import javax.swing.text.View;
40 import javax.swing.text.html.StyleSheet;
41 import javax.swing.text.html.HTMLDocument;
42
43 public class bug4960629 {
44 private boolean passed = false;
45 private JLabel label = null;
46 private JFrame f = null;
47
48 public void createAndShowGUI() throws Exception {
49 try {
50 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
51 label = new JLabel("<html><P>This is a test of the</P></html>");
52 System.out.println("UIManager.getLookAndFeel()"
53 + UIManager.getLookAndFeel().getClass());
54 f = new JFrame();
55 f.getContentPane().add(label);
56 f.pack();
57 f.setVisible(true);
58 test();
59 } finally {
60 f.dispose();
61 }
62 }
63
64 bug4960629() throws InvocationTargetException, InterruptedException {
65 SwingUtilities.invokeAndWait(new Runnable() {
66 @Override
67 public void run() {
68 try {
69 createAndShowGUI();
70 } catch (Exception e) {
71 throw new RuntimeException("Exception "
72 + e.getMessage());
73 }
74 }
75 });
76 }
77
78 private void test() {
79 View root = ((View)label.getClientProperty(BasicHTML.propertyKey))
80 .getView(0);
|
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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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.
22 */
23
24 /**
25 * @test
26 * @key headful
27 * @bug 4960629 7124238
28 * @summary Tests if font for html text on widgets in correct.
29 * @author Denis Sharypov
30 * @run main bug4960629
31 */
32
33 import java.awt.Font;
34 import java.lang.reflect.InvocationTargetException;
35 import javax.swing.JFrame;
36 import javax.swing.JLabel;
37 import javax.swing.SwingUtilities;
38 import javax.swing.UIManager;
39 import javax.swing.plaf.basic.BasicHTML;
40 import javax.swing.text.AttributeSet;
41 import javax.swing.text.View;
42 import javax.swing.text.html.StyleSheet;
43 import javax.swing.text.html.HTMLDocument;
44
45 public class bug4960629 {
46 private boolean passed = false;
47 private JLabel label = null;
48 private JFrame f = null;
49
50 public void createAndShowGUI() throws Exception {
51 try {
52 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
53 label = new JLabel("<html><P>This is a test of the</P></html>");
54 System.out.println("UIManager.getLookAndFeel()"
55 + UIManager.getLookAndFeel().getClass());
56 f = new JFrame();
57 f.getContentPane().add(label);
58 f.pack();
59 f.setVisible(true);
60 test();
61 } finally {
62 if (f != null) { f.dispose(); }
63 }
64 }
65
66 bug4960629() throws InvocationTargetException, InterruptedException {
67 SwingUtilities.invokeAndWait(new Runnable() {
68 @Override
69 public void run() {
70 try {
71 createAndShowGUI();
72 } catch (Exception e) {
73 throw new RuntimeException("Exception "
74 + e.getMessage());
75 }
76 }
77 });
78 }
79
80 private void test() {
81 View root = ((View)label.getClientProperty(BasicHTML.propertyKey))
82 .getView(0);
|