Java Reference
In-Depth Information
Creating a JEditorPane
The JEditorPane has four constructors:
public JEditorPane()
JEditorPane editorPane = new JEditorPane();
public JEditorPane(String type, String text)
String content = "<H1>Got Java?</H1>";
String type = "text/html";
JEditorPane editorPane = new JEditorPane(type, content);
public JEditorPane(String urlString) throws IOException
JEditorPane editorPane = new JEditorPane("http://www.apress.com");
public JEditorPane(URL url) throws IOException
URL url = new URL("http://www.apress.com");
JEditorPane editorPane = new JEditorPane(url);
The no-argument constructor creates an empty JEditorPane . If you want to initialize the
contents, you can directly specify the text and its MIME type. Or, you can specify the URL for
where to get the contents. The URL can be specified as either a String or a URL object. When
you specify the contents as a URL, the JEditorPane determines the MIME type from the response.
JEditorPane Properties
Table 15-12 shows the 11 properties of JEditorPane . Most of the properties just customize the
behavior of the parent classes.
Table 15-12. JEditorPane Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
contentType
String
Read-write
editorKit
EditorKit
Read-write bound
hyperlinkListeners
HyperlinkListener[ ]
Read-only
page
URL
Read-write bound
page
String
Write-only bound
preferredSize
Dimension
Read-only
scrollableTracksViewportHeight
boolean
Read-only
scrollableTracksViewportWidth
boolean
Read-only
text
String
Read-write
UIClassID
String
Read-only
Search WWH ::




Custom Search