A powerful text editor component that can handle different types of
content.
The JEditorPane text component is driven by an instance of
EditorKit
. The editor kit is responsible for providing
a default
Document
implementation, a mechanism for loading
and saving documents of its supported content type and providing
a set of
Action
s for manipulating the content.
By default the following content types are supported:
createEditorKitForContentType
public static EditorKit createEditorKitForContentType(String type)
Creates and returns an EditorKit that is appropriate for the given
content type. This is created using the default recognized types
plus any EditorKit types that have been registered.
- an EditorKit for use with the given content type
getEditorKit
public EditorKit getEditorKit()
Returns the EditorKit. If there is no EditorKit set this method
calls createDefaultEditorKit() and setEditorKit() first.
getEditorKitClassNameForContentType
public static String getEditorKitClassNameForContentType(String type)
Returns the class name of the EditorKit associated with the given
content type.
- the class name of the EditorKit associated with this content type
getEditorKitForContentType
public EditorKit getEditorKitForContentType(String type)
Returns the EditorKit to use for the given content type. If an
EditorKit has been explicitly set via
setEditorKitForContentType
then it will be returned. Otherwise an attempt will be made to create
an EditorKit from the default recognzied content types or any
EditorKits that have been registered. If none can be created, a
PlainEditorKit is created.
- an appropriate EditorKit for the given content type
registerEditorKitForContentType
public static void registerEditorKitForContentType(String type,
String classname)
Establishes a binding between type and classname. This enables
us to create an EditorKit later for the given content type.
type
- the content typeclassname
- the name of the class that is associated with this
content type
scrollToReference
public void scrollToReference(String reference)
Scrolls the view to the given reference location (that is, the value
returned by the UL.getRef method for the URL being displayed).
setEditorKitForContentType
public void setEditorKitForContentType(String type,
EditorKit k)
Explicitly sets an EditorKit to be used for the given content type.
type
- the content typek
- the EditorKit to use for the given content type
setText
public void setText(String t)
Sets the text of the JEditorPane. The argument t
is expected to be in the format of the current EditorKit. This removes
the content of the current document and uses the EditorKit to read in the
new text. This allows the EditorKit to handle the String rather than just
inserting in plain text.
- setText in interface JTextComponent
t
- the text to display in this JEditorPane
JEditorPane.java --
Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.