Show html : JEditorPane « Swing « Java Tutorial






import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class Main {
  public static void main(String[] args) throws Exception {
    JEditorPane editor = new JEditorPane("text/html",
        "<H1>A!</H1><P><FONT COLOR=blue>blue</FONT></P>");
    editor.setEditable(false);
    JScrollPane pane = new JScrollPane(editor);
    JFrame f = new JFrame("HTML Demo");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(pane);
    f.setSize(800, 600);
    f.setVisible(true);
  }
}








14.35.JEditorPane
14.35.1.Loading HTML Documents as a StyledDocument into a JEditorPane
14.35.2.Loading Web Page To JEditorPaneLoading Web Page To JEditorPane
14.35.3.Using Actions with Text Components: JEditorPane
14.35.4.Show html
14.35.5.Change mouse cursor during mouse-over action on hyperlinks
14.35.6.JEditorPane Look and Feel
14.35.7.How to change mouse cursor during mouse-over action on hyperlinks