Normand Briere
2018-07-07 09ddd38fd4a8a7100c834a5e976f4796fae53541
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package timeflow.app.ui;
 
import java.awt.Font;
 
import javax.swing.JEditorPane;
import javax.swing.UIManager;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;
 
public class HtmlDisplay {
   public static JEditorPane create()
   {
       JEditorPane p = new JEditorPane();
       p.setEditable(false);
       p.setContentType("text/html");
       
       Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: "+font.getFamily()+"; "+
                "font-size: " + font.getSize() + "pt; }";
        StyleSheet styles=((HTMLDocument)p.getDocument()).getStyleSheet();
        styles.addRule(bodyRule);
        return p;
   }
}