
Be aware that the read and write methods for StyleEditorKit work with plain text. A text pane also requires that its editor kit be an instance of a StyledEditorKit (or a subclass). The Swing text package provides a default implementation of this interface, DefaultStyledDocument, which is the document that text panes use by default.
#Does textpad 8 support java gui how to#
#Does textpad 8 support java gui code#
If your program uses the setPage method, make sure you adjust your code for possible changes to the pane's document and editor kit instances (re-register document listeners on the new document, and so on). For example, if an editor pane contains plain text (the default), and you load it with HTML, the document will change to an HTMLDocument instance and the editor kit will change to an HTMLEditorKit instance. See Using an Editor Pane to Display Text From a URL for an example that uses this feature to load an uneditable editor pane with HTML-formatted text.īe aware that the document and editor kit might change when using the setPage method. The JTextPane class has no such constructors. The JEditorPane class also provides constructors that let you initialize an editor pane from a URL. An editor pane or a text pane can easily be loaded with text from a URL using the setPage method.The information here should help you understand the differences between editor panes and text panes, and when to use which. Here we list the facts again and provide a bit more detail.

Several facts about editor panes and text panes are scattered throughout that section. In order to use editor panes and text panes, you need to understand the text system, which is described in Text Component Features. Note that the page might be loaded asynchronously, which keeps the GUI responsive but means that you should not count on the data being completely loaded after the call to setPage returns.

A standard editor pane can understand plain text, HTML, and RTF. If the text format is known, the editor pane initializes itself with the text found at the URL. The setPage method opens the resource pointed to by the URL and figures out the format of the text (which is HTML in the example).

Next, the code creates the URL object, and calls the setPage method with it. The code uses the default constructor to create the editor pane, then calls setEditable(false) so the user cannot edit the text. JScrollPane editorScrollPane = new JScrollPane(editorPane) ĮtVerticalScrollBarPolicy(ĮtPreferredSize(new Dimension(250, 145)) ĮtMinimumSize(new Dimension(10, 10)) ("Couldn't find file: TextSamplerDemoHelp.html")

("Attempted to read a bad URL: " + helpURL) JEditorPane editorPane = new JEditorPane()
