Class HTMLEditorKit
java.lang.Object
javax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
javax.swing.text.StyledEditorKit
javax.swing.text.html.HTMLEditorKit
vaadinx.swing.text.html.HTMLEditorKit
- All Implemented Interfaces:
Serializable, Cloneable, Accessible
Emulator for
HTMLEditorKit — the carrier for
author CSS on an HTML JEditorPane. Supports the field's dominant
render-only idiom:
JEditorPane pane = new JEditorPane();
HTMLEditorKit kit = new HTMLEditorKit();
pane.setEditorKit(kit);
kit.getStyleSheet().addRule("body { font-family: sans-serif; }");
pane.setEditable(false);
pane.setText("<h2>Report</h2><ul><li>one</li></ul>");
Scope: the stylesheet, not the rendering pipeline
The kit's job here is to carry aStyleSheet to the pane. It does
not drive rendering: Vaadin's RichTextEditor renders the pane's
HTML, and the JDK's rendering path is built on View.paint(Graphics, …),
permanently out of scope per R_match_swing_errors sub-bucket (b). So HTMLEditorKit.getViewFactory()
answers with a real factory (inherited, so subclassing it compiles) but nothing
consults it — a custom ViewFactory is inert. That costs migrated code
nothing in the one idiom that actually appears in the field: a factory that
refuses <img> views so a report pane never hits the network, which is
already our behaviour since images outside base64 data-URLs are dropped anyway.
Headless parsing needs nothing from us
Code that uses this class purely as an HTML scraper — aParserCallback
handed to javax.swing.text.html.parser.ParserDelegator, no pane in sight
— keeps working after an import swap, because the nested callback types are the
JDK's own by inheritance. The one seam that does not survive is subclassing
Parser itself: an override written as parse(Reader, ParserCallback,
boolean) resolves the parameter to this class's inherited nested type, which is
the JDK type, so it compiles — but a hand-written signature naming a
vaadinx callback type would not. ParserDelegator is the
documented way in, so this is a corner rather than a road.
What drops-and-WARNs
insertHTML(HTMLDocument, int, String, int, int, HTML.Tag) — splicing markup into an HTMLDocument needs the
element model that is not built (there is no HTMLDocument behind the
pane; the emulator keeps a PlainDocument). read / write
likewise: the pane's own setText / getText are the supported way
in and out.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class HTMLEditorKit
HTMLEditorKit.HTMLFactory, HTMLEditorKit.HTMLTextAction, HTMLEditorKit.InsertHTMLTextAction, HTMLEditorKit.LinkController, HTMLEditorKit.Parser, HTMLEditorKit.ParserCallbackNested classes/interfaces inherited from class StyledEditorKit
StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineActionNested classes/interfaces inherited from class DefaultEditorKit
DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction -
Field Summary
Fields inherited from class HTMLEditorKit
BOLD_ACTION, COLOR_ACTION, DEFAULT_CSS, FONT_CHANGE_BIGGER, FONT_CHANGE_SMALLER, IMG_ALIGN_BOTTOM, IMG_ALIGN_MIDDLE, IMG_ALIGN_TOP, IMG_BORDER, ITALIC_ACTION, LOGICAL_STYLE_ACTION, PARA_INDENT_LEFT, PARA_INDENT_RIGHTFields inherited from class DefaultEditorKit
backwardAction, beepAction, beginAction, beginLineAction, beginLineUpAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deleteNextWordAction, deletePrevCharAction, deletePrevWordAction, downAction, endAction, endLineAction, endLineDownAction, 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid_bindTo(com.vaadin.swingbridge.surrogates.SJEditorPane peer) Framework-internal (the_prefix marks it, as on_installSwingClass): bind this kit's stylesheet to a pane's peer.This kit's own stylesheet.voidinsertHTML(HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag insertTag) voidInstall a stylesheet.Methods inherited from class HTMLEditorKit
clone, createDefaultDocument, createInputAttributes, deinstall, getAccessibleContext, getActions, getContentType, getDefaultCursor, getInputAttributes, getLinkCursor, getParser, getViewFactory, install, isAutoFormSubmission, read, setAutoFormSubmission, setDefaultCursor, setLinkCursor, writeMethods inherited from class StyledEditorKit
getCharacterAttributeRunMethods inherited from class DefaultEditorKit
createCaret, read, write
-
Constructor Details
-
HTMLEditorKit
public HTMLEditorKit()
-
-
Method Details
-
getStyleSheet
This kit's own stylesheet. Unlike the JDK, the sheet is not shared with other kits — seeStyleSheetfor the rationale.- Overrides:
getStyleSheetin classHTMLEditorKit
-
setStyleSheet
Install a stylesheet. Avaadinxsheet takes effect; a JDK-typed sheet has no way to reach the peer and WARNs, leaving the current one in place — failing to style is better than silently accepting a sheet that can never apply.- Overrides:
setStyleSheetin classHTMLEditorKit
-
_bindTo
public void _bindTo(com.vaadin.swingbridge.surrogates.SJEditorPane peer) Framework-internal (the_prefix marks it, as on_installSwingClass): bind this kit's stylesheet to a pane's peer. Called byJEditorPane.setEditorKitfrom a sibling package; the peer is remembered so a latersetStyleSheet(StyleSheet)reaches it too. Not part of the emulated JDK surface — migrated code has no reason to call it. -
insertHTML
public void insertHTML(HTMLDocument doc, int offset, String html, int popDepth, int pushDepth, HTML.Tag insertTag) - Overrides:
insertHTMLin classHTMLEditorKit
-