/Users/lyon/j4p/src/gui/html/HtmlViewer.java

1    package gui.html; 
2     
3    import gui.ClosableJFrame; 
4     
5    import javax.swing.*; 
6     
7     
8    public class HtmlViewer extends ClosableJFrame { 
9        private JEditorPane htmlPane 
10               = new JEditorPane(); 
11       private JEditorPane textPane 
12               = new JEditorPane(); 
13    
14       public HtmlViewer() { 
15           super("HtmlViewer"); 
16           java.awt.Container c = getContentPane(); 
17           c.setLayout(new java.awt.GridLayout(1, 0)); 
18           c.add(new javax.swing.JScrollPane(htmlPane)); 
19           c.add(new javax.swing.JScrollPane(textPane)); 
20           setSize(400, 400); 
21           setVisible(true); 
22       } 
23    
24       public void setHtml(String s) { 
25           htmlPane.setContentType("text/html"); 
26           htmlPane.setText(s); 
27       } 
28    
29       public void setRtfText(String s) { 
30           textPane.setContentType("text/rtf"); 
31           textPane.setText(s); 
32       } 
33    
34       public void setPlainText(String s) { 
35           textPane.setContentType("text/plain"); 
36           textPane.setText(s); 
37       } 
38    
39       public void setString(String s) { 
40           setPlainText(s); 
41           setHtml(s); 
42           System.out.println(s); 
43       } 
44    
45       public static void main(String args[]) { 
46           HtmlViewer hv = new HtmlViewer(); 
47           HtmlSynthesizer hs = new HtmlSynthesizer(); 
48           hv.setString(hs.testForm2()); 
49       } 
50   }