All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.JEditorPane
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----com.sun.java.swing.text.JTextComponent
|
+----com.sun.java.swing.JEditorPane
- public class JEditorPane
- extends JTextComponent
A text pane to edit various kinds of content, such
as html and rtf. This uses implementations of the
EditorKit to accomplish it's behavior. This component
effectively morphs into the proper kind of text editor
for the kind of content it is given.
The content type that editor is bound to at any given
time is determined by the EditorKit currently installed.
If the content is set to a new URL, it's type is used
to determine the EditorKit that should be used to load
the content.
Warning: serialized objects of this class will not be compatible with
future swing releases. The current serialization support is appropriate
for short term storage or RMI between Swing1.0 applications. It will
not be possible to load serialized Swing1.0 objects with future releases
of Swing. The JDK1.2 release of Swing will be the compatibility
baseline for the serialized form of Swing objects.
-
JEditorPane()
- Constructs a new JEditorPane.
-
JEditorPane(String)
- Creates a JEditorPane based on a string containing a URL specification.
-
JEditorPane(URL)
- Creates a JEditorPane based on a specified URL for input.
-
addHyperlinkListener(HyperlinkListener)
- Adds a hyperlink listener for notification of any changes.
-
createDefaultEditorKit()
- Creates the default editor kit for when
the component is first created.
-
createEditorKitForContentType(String)
- Create a handler for the given type from the default registry
of editor kits.
-
fireHyperlinkUpdate(HyperlinkEvent)
- Notifies all listeners that have registered interest for
notification on this event type.
-
getAccessibleContext()
- Get the AccessibleContext associated with this JEditorPane
-
getContentType()
- Gets the type of content that this editor
handles.
-
getEditorKit()
- Fetches the currently installed kit for handling
content.
-
getEditorKitForContentType(String)
- Fetches the editor kit to use for the given type
of content.
-
getPage()
- Gets the current url being displayed.
-
getScrollableTracksViewportWidth()
- Returns true if a viewport should always force the width of this
Scrollable to match the width of the viewport.
-
getUIClassID()
- Gets the class ID for the UI.
-
isManagingFocus()
- Turns off tab traversal once focus gained.
-
registerEditorKitForContentType(String, String)
- Establishes the default bindings of type to name.
-
removeHyperlinkListener(HyperlinkListener)
- Removes a hyperlink listener.
-
setContentType(String)
- Sets the type of content that this editor
handles.
-
setEditorKit(EditorKit)
- Sets the currently installed kit for handling
content.
-
setEditorKitForContentType(String, EditorKit)
- Directly set the editor kit to use for the given type.
-
setPage(String)
- Sets the current url being displayed.
-
setPage(URL)
- Sets the current url being displayed.
JEditorPane
public JEditorPane()
- Constructs a new JEditorPane.
JEditorPane
public JEditorPane(URL initialPage) throws IOException
- Creates a JEditorPane based on a specified URL for input.
- Parameters:
- initialPage - the URL
- Throws: IOException
- if the URL cannot be accessed
JEditorPane
public JEditorPane(String url) throws IOException
- Creates a JEditorPane based on a string containing a URL specification.
- Parameters:
- url - the URL
- Throws: IOException
- if the URL cannot be accessed
addHyperlinkListener
public synchronized void addHyperlinkListener(HyperlinkListener listener)
- Adds a hyperlink listener for notification of any changes.
- Parameters:
- listener - the listener
removeHyperlinkListener
public synchronized void removeHyperlinkListener(HyperlinkListener listener)
- Removes a hyperlink listener.
- Parameters:
- listener - the listener
fireHyperlinkUpdate
public void fireHyperlinkUpdate(HyperlinkEvent e)
- Notifies all listeners that have registered interest for
notification on this event type. This is normally called
by the currently installed EditorKit if a content type
that supports hyperlinks is currently active and there
was activity with a link.
- Parameters:
- e - the event
- See Also:
- EventListenerList
setPage
public void setPage(URL page) throws IOException
- Sets the current url being displayed.
- Parameters:
- page - the URL of the page
- Throws: IOException
- for an invalid page specification
getPage
public URL getPage()
- Gets the current url being displayed. If a URL was
not specified in the creation of the document, this
will return null, and relative URL's will not be
resolved.
- Returns:
- the URL
setPage
public void setPage(String url) throws IOException
- Sets the current url being displayed.
- Parameters:
- url - the URL for display
- Throws: IOException
- for an invalid URL specification
getUIClassID
public String getUIClassID()
- Gets the class ID for the UI.
- Returns:
- the ID
- Overrides:
- getUIClassID in class JComponent
- See Also:
- getUIClassID, getUI
createDefaultEditorKit
protected EditorKit createDefaultEditorKit()
- Creates the default editor kit for when
the component is first created.
getEditorKit
public final EditorKit getEditorKit()
- Fetches the currently installed kit for handling
content.
- Returns:
- the editor kit
getContentType
public final String getContentType()
- Gets the type of content that this editor
handles.
- Returns:
- the content type
setContentType
public final void setContentType(String type)
- Sets the type of content that this editor
handles. This calls
getEditorKitForContentType
and setEditorKit
if and editor kit can
be successfully located. This is a convenience method
that can be used as an alternative to calling
setEditorKit
directly.
- Parameters:
- type - the mime type for the content editing
support.
- See Also:
- getContentType
setEditorKit
public void setEditorKit(EditorKit kit)
- Sets the currently installed kit for handling
content. This is the bound property that
establishes the content type of the editor.
- Parameters:
- kit - the desired editor behavior.
- See Also:
- getEditorKit
getEditorKitForContentType
public EditorKit getEditorKitForContentType(String type)
- Fetches the editor kit to use for the given type
of content. This is called when a type is requested
that doesn't match the currently installed type.
If the component doesn't have an EditorKit registered
for the given type, it will try to create an
EditorKit from the default EditorKit registry.
If that fails, a DefaultEditorKit is used on the
assumption that all text documents can be represented
as plain text.
This method can be reimplemented to use some
other kind of type registry. This can
be reimplemented to use the Java Activation
Framework for example.
- Parameters:
- type - the content type
- Returns:
- the editor kit
setEditorKitForContentType
public void setEditorKitForContentType(String type,
EditorKit k)
- Directly set the editor kit to use for the given type. A
look-and-feel implementation might use this in conjunction
with createEditorKitForContentType to install handlers for
content types with a look-and-feel bias.
createEditorKitForContentType
public static EditorKit createEditorKitForContentType(String type)
- Create a handler for the given type from the default registry
of editor kits.
registerEditorKitForContentType
public static void registerEditorKitForContentType(String type,
String classname)
- Establishes the default bindings of type to name.
The class will be dynamically loaded later when actually
needed, and can be safely changed before attempted uses
to avoid loading unwanted classes.
- Parameters:
- type - the content type
- classname - the class to load later
isManagingFocus
public boolean isManagingFocus()
- Turns off tab traversal once focus gained.
- Returns:
- true, to indicate that the focus is being managed
- Overrides:
- isManagingFocus in class JComponent
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Returns true if a viewport should always force the width of this
Scrollable to match the width of the viewport.
- Returns:
- True if a viewport should force the Scrollables width to match its own.
- Overrides:
- getScrollableTracksViewportWidth in class JTextComponent
getAccessibleContext
public AccessibleContext getAccessibleContext()
- Get the AccessibleContext associated with this JEditorPane
- Returns:
- the AccessibleContext of this JEditorPane
- Overrides:
- getAccessibleContext in class JTextComponent
All Packages Class Hierarchy This Package Previous Next Index