Java Swing Tutorial – Java Swing JEditorPane. A JEditorPane is a text component that can handle different text with style. By default, it can handle plain text. Did you know that you can use CSS styles when displaying HTML in a Java Swing application? It’s pretty cool, and it can help spice up any. You can use either of them, but if it is a rich text editor then I would suggest using the JTextPane. You may also find this topic useful.

Author: Malagor Kajigore
Country: Cyprus
Language: English (Spanish)
Genre: Love
Published (Last): 20 November 2013
Pages: 32
PDF File Size: 5.6 Mb
ePub File Size: 20.57 Mb
ISBN: 408-4-95883-434-8
Downloads: 10268
Price: Free* [*Free Regsitration Required]
Uploader: Diramar

How to Use Editor Panes and Text Panes

If the size of the viewport has become smaller than the minimum size of the component, the scrollable definition for tracking width or height will turn to false.

If the document is successfully loaded and installed, a view will be built for it by the UI which will then be scrolled if necessary, and then the page property change event will be fired. This component uses implementations of the EditorKit to accomplish its behavior.

IOException – for a null or invalid page specification, or exception from the stream being read See Also: String getContentType Gets the type of content that this editor is currently set to deal with. Alternatively, to compile and run the example yourself, consult the example index. How to Use File Choosers. This is normally called by the currently installed EditorKit if a content type that supports hyperlinks is currently active and there was activity with a link.

The implementation calls the scrollRectToVisible method to accomplish the actual scrolling.

The registry is created if necessary. You can find how-to information and examples of using editor panes in Using Text Componentsa section in The Java Tutorial.


This requires reading the document prior to determining the character set that is desired. Returns true if a viewport should always force the width of this Scrollable to match the width of the viewport. Some kinds of content may provide hyperlink support by generating hyperlink events.

Provides a customized text pane. Key for a client property used to indicate whether w3c compliant length units are used for html rendering. The class will be dynamically loaded later when actually needed using the given ClassLoaderand can be safely changed before attempted uses to avoid loading unwanted classes. You can use either of them, but if it is a rich text editor then I would suggest using the JTextPane.

Jeitorpane encoding is an unambiguous mapping of the members of a character set letters, ideographs, digits, symbols, or control functions to specific numeric code nava. Creates a JEditorPane that has been initialized to the given text. Notifies all listeners that have registered interest for notification on this jeditorpanr type.

This section lists some of the API related to text and editor panes. This is mostly convenience method that can be used as an alternative to calling setEditorKit directly. Another jaga the character set can be specified is in the document itself. It will also be fired on the event-dispatch thread. Sets the currently installed kit for handling content. If there was no registered ClassLoaderClass.

In this case, the page property change event will not be fired by the call to this method directly, but rather will be fired when the thread doing the loading has finished.

This has the side effect of changing the model, because the EditorKit is the source of how a particular type of content is modeled. This is implemented to remove the contents of the current document, and replace them by parsing the given string using the current EditorKit.


Once a prototype EditorKit instance is successfully located, it is cloned and the clone is returned. Sets the type of content that this editor handles.

Sets the text of this TextComponent to the specified content, which is expected to be in the format of the content type of this editor. It effectively morphs into the proper kind of text editor for the kind of content it is given. There are multiple ways to get a jeditogpane set mapping to happen with JEditorPane. Returns a string representation of this JEditorPane. Fetches a stream for the given URL, which is about to be loaded by the setPage method.

The kit used in this case is an extension of DefaultEditorKit that produces a wrapped plain text jzva.

JEditorPane (Java Platform SE 7 )

Gets the current URL being displayed. Post as a guest Name. Returns true if a viewport should always force the height of this Scrollable to match the height of the viewport. This can be reimplemented to use the Java Activation Framework, for example. Please tell me suitable difference between these two that in which kind of situation i have to use one of these. Creates the default editor kit PlainEditorKit for when the component is first created.

Two Swing classes support styled text: By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. To avoid this, create a new document, getEditorKit. Creates a new JEditorPane.

In that case the normal preferred size is adjusted to the minimum size. Sign up or log in Sign up using Google.