public class HTMLEditorKit extends StyledEditorKit implements Serializable, Cloneable, Accessible
Modifier and Type | Class and Description |
---|---|
static class |
HTMLEditorKit.HTMLFactory
|
static class |
HTMLEditorKit.HTMLTextAction
Abstract Action class that helps inserting HTML into an existing document.
|
static class |
HTMLEditorKit.InsertHTMLTextAction
This class is used to insert a string of HTML into an existing
document.
|
static class |
HTMLEditorKit.LinkController
Fires the hyperlink events on the associated component
when needed.
|
static class |
HTMLEditorKit.Parser
The abstract HTML parser declaration.
|
static class |
HTMLEditorKit.ParserCallback
The "hook" that receives all information about the HTML document
structure while parsing it.
|
StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineAction
DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction
Modifier and Type | Field and Description |
---|---|
static String |
BOLD_ACTION
The bold action identifier.
|
static String |
COLOR_ACTION
The color action indentifier
(passing the color as an argument).
|
static String |
DEFAULT_CSS
Default cascading stylesheed file ("default.css").
|
static String |
FONT_CHANGE_BIGGER
The increase font action identifier.
|
static String |
FONT_CHANGE_SMALLER
The decrease font action identifier.
|
static String |
IMG_ALIGN_BOTTOM
Align images at the bottom.
|
static String |
IMG_ALIGN_MIDDLE
Align images at the middle.
|
static String |
IMG_ALIGN_TOP
Align images at the top.
|
static String |
IMG_BORDER
Align images at the border.
|
static String |
ITALIC_ACTION
The italic action identifier.
|
static String |
LOGICAL_STYLE_ACTION
The "logical style" action identifier, passing that style as parameter.
|
static String |
PARA_INDENT_LEFT
The "ident paragraph left" action.
|
static String |
PARA_INDENT_RIGHT
The "ident paragraph right" action.
|
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deletePrevCharAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction
Constructor and Description |
---|
HTMLEditorKit()
Constructs an HTMLEditorKit, creates a StyleContext, and loads the style sheet.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates a copy of the editor kit.
|
Document |
createDefaultDocument()
Create a text storage model for this type of editor.
|
protected void |
createInputAttributes(Element element,
MutableAttributeSet set)
Copies the key/values in elements AttributeSet into set.
|
void |
deinstall(JEditorPane c)
Called when the this is removed from the JEditorPane.
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this.
|
Action[] |
getActions()
Gets the action list.
|
String |
getContentType()
Gets the content type that the kit supports.
|
Cursor |
getDefaultCursor()
Returns the default cursor.
|
MutableAttributeSet |
getInputAttributes()
Gets the input attributes used for the styled editing actions.
|
Cursor |
getLinkCursor()
Returns the cursor for links.
|
protected HTMLEditorKit.Parser |
getParser()
Get the parser that this editor kit uses for reading HTML streams.
|
StyleSheet |
getStyleSheet()
Get the set of styles currently being used to render the HTML elements.
|
ViewFactory |
getViewFactory()
Gets a factory suitable for producing views of any
models that are produced by this kit.
|
void |
insertHTML(HTMLDocument doc,
int offset,
String html,
int popDepth,
int pushDepth,
HTML.Tag insertTag)
Inserts HTML into an existing document.
|
void |
install(JEditorPane c)
Called when this is installed into the JEditorPane.
|
boolean |
isAutoFormSubmission()
Returns
true when forms should be automatically submitted
by the editor kit. |
void |
read(Reader in,
Document doc,
int pos)
Inserts content from the given stream.
|
void |
setAutoFormSubmission(boolean auto)
Sets whether or not the editor kit should automatically submit forms.
|
void |
setDefaultCursor(Cursor cursor)
Sets the default cursor.
|
void |
setLinkCursor(Cursor cursor)
Sets the Cursor for links.
|
void |
setStyleSheet(StyleSheet s)
Set the set of styles to be used to render the various HTML elements.
|
void |
write(Writer out,
Document doc,
int pos,
int len)
Writes content from a document to the given stream in
an appropriate format.
|
getCharacterAttributeRun
createCaret, read, write
public static final String DEFAULT_CSS
public static final String BOLD_ACTION
public static final String ITALIC_ACTION
public static final String COLOR_ACTION
public static final String FONT_CHANGE_BIGGER
public static final String FONT_CHANGE_SMALLER
public static final String IMG_ALIGN_BOTTOM
public static final String IMG_ALIGN_MIDDLE
public static final String IMG_ALIGN_TOP
public static final String IMG_BORDER
public static final String LOGICAL_STYLE_ACTION
public static final String PARA_INDENT_LEFT
public static final String PARA_INDENT_RIGHT
public HTMLEditorKit()
public ViewFactory getViewFactory()
getViewFactory
in class StyledEditorKit
public Document createDefaultDocument()
createDefaultDocument
in class StyledEditorKit
protected HTMLEditorKit.Parser getParser()
ParserDelegator
).public void insertHTML(HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag insertTag) throws BadLocationException, IOException
doc
- - the Document to insert the HTML into.offset
- - where to begin inserting the HTML.html
- - the String to insertpopDepth
- - the number of ElementSpec.EndTagTypes
to generate before insertingpushDepth
- - the number of ElementSpec.StartTagTypes
with a direction of ElementSpec.JoinNextDirection that
should be generated beforeinsertTag
- - the first tag to start inserting into documentIOException
- - on any I/O errorBadLocationException
- - if pos represents an invalid location
within the documentpublic void read(Reader in, Document doc, int pos) throws IOException, BadLocationException
read
in class DefaultEditorKit
in
- - the stream to read fromdoc
- - the destination for the insertionpos
- - the location in the document to place the contentIOException
- - on any I/O errorBadLocationException
- - if pos represents an invalid location
within the documentpublic void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
write
in class DefaultEditorKit
out
- - the stream to write todoc
- - the source for the writepos
- - the location in the document to get the content.len
- - the amount to write outIOException
- - on any I/O errorBadLocationException
- - if pos represents an invalid location
within the documentpublic String getContentType()
getContentType
in class DefaultEditorKit
EditorKit
supportspublic Object clone()
clone
in class StyledEditorKit
Cloneable
protected void createInputAttributes(Element element, MutableAttributeSet set)
createInputAttributes
in class StyledEditorKit
element
- - the element to create the input attributes for.set
- - the set to copy the values into.public void install(JEditorPane c)
install
in class StyledEditorKit
c
- - the JEditorPane installed into.public void deinstall(JEditorPane c)
deinstall
in class StyledEditorKit
c
- - the JEditorPane being removed from.public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
public Action[] getActions()
getActions
in class StyledEditorKit
public Cursor getDefaultCursor()
public Cursor getLinkCursor()
public void setLinkCursor(Cursor cursor)
cursor
- - the new cursor for links.public void setDefaultCursor(Cursor cursor)
cursor
- - the new default cursor.public MutableAttributeSet getInputAttributes()
getInputAttributes
in class StyledEditorKit
public StyleSheet getStyleSheet()
public void setStyleSheet(StyleSheet s)
s
- - the new style sheetpublic boolean isAutoFormSubmission()
true
when forms should be automatically submitted
by the editor kit. Set this to false
when you want to
intercept form submission. In this case you'd want to listen for
hyperlink events on the document and handle FormSubmitEvents specially.
The default is true
.true
when forms should be automatically submitted
by the editor kit, false
otherwisesetAutoFormSubmission(boolean)
,
FormSubmitEvent
public void setAutoFormSubmission(boolean auto)
auto
- true
when the editor kit should handle form
submission, false
otherwiseisAutoFormSubmission()