Previous | Next | Trail Map | Creating a GUI with JFC/Swing | Using Swing Components

How to Use Editor Panes and TextPanes

JEditorPane(in the API reference documentation)

JTextPane(in the API reference documentation)

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 to JTextPane.

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 using JEditorPane's registerEditorKitForContentType to associate your kit with your text format.


Previous | Next | Trail Map | Creating a GUI with JFC/Swing | Using Swing Components