KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > util > InfoViewTextPane


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18

19 package org.columba.core.gui.util;
20
21 import java.awt.Font JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.net.URL JavaDoc;
24
25 import javax.swing.JTextPane JavaDoc;
26 import javax.swing.UIManager JavaDoc;
27 import javax.swing.text.html.HTMLEditorKit JavaDoc;
28 import javax.swing.text.html.StyleSheet JavaDoc;
29
30 /**
31  * Customized HTML JTextPane.
32  *
33  * @author fdietz
34  */

35 public class InfoViewTextPane extends JTextPane JavaDoc {
36     
37     /**
38      *
39      */

40     public InfoViewTextPane() {
41         super();
42         
43         HTMLEditorKit JavaDoc editorKit = new HTMLEditorKit JavaDoc();
44         StyleSheet JavaDoc styles = new StyleSheet JavaDoc();
45         
46         Font JavaDoc font = UIManager.getFont("Label.font");
47         String JavaDoc name = font.getName();
48         int size = font.getSize();
49         String JavaDoc css = "<style type=\"text/css\"><!--p {font-family:\"" + name
50             + "\"; font-size:\"" + size + "pt\"}--></style>";
51         styles.addRule(css);
52         editorKit.setStyleSheet(styles);
53         
54         setEditorKit(editorKit);
55     }
56     
57     /**
58      * @param url
59      */

60     public InfoViewTextPane(URL JavaDoc url) throws IOException JavaDoc {
61         this();
62         setPage(url);
63     }
64 }
65
Popular Tags