Java JEditorPane(String type, String text) Constructor
Syntax
JEditorPane(String type, String text) constructor from JEditorPane has the following syntax.
public JEditorPane(String type, String text)
Example
In the following code shows how to use JEditorPane.JEditorPane(String type, String text) constructor.
/* ww w . j a v a 2 s . com*/
import java.awt.BorderLayout;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
public class Main {
public static void main(String args[]) {
JFrame f = new JFrame("JEditorPane Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JEditorPane editor = new JEditorPane(
"text/html",
"<H3>Help</H3><center>www.java2s.com</center><li>One<li><i>Two</i><li><u>Three</u>");
editor.setEditable(false);
JScrollPane scrollPane = new JScrollPane(editor);
f.add(scrollPane, BorderLayout.CENTER);
f.setSize(300, 200);
f.setVisible(true);
}
}
Home »
Java Tutorial »
javax.swing »
Java Tutorial »
javax.swing »