Using Swing Components |
JEditorPane
The first thing most people want to know is: What's the difference between an editor pane and a text pane? First this section attempt answers that question. Next, this section describes the code in the
TextSamplerDemo
specific toJTextPane
.Each of these editor kits has been registered with the
JEditorPane
class and associated with the text format that the kit understands. When a file is loaded into an editor pane, the pane checks the format of the file against its registered kits. If a registered kit is found that supports that file format, the pane uses the kit to read the file, display, and edit it. Thus, the editor pane effectively morphs itself into an editor for that text format.You can extend
JEditorPane
to support your own text format by creating an editor kit for it, and then usingJEditorPane
'sregisterEditorKitForContentType
to associate your kit with your text format.
Using Swing Components |