Using a JEditorPane to display a web page. import *; import *; import *; import *; public class. The JEditorPane class is the foundation for Swing’s styled text components and provides a mechanism Using an Editor Pane to Display Text From a URL. This class implements accessibility support for the JEditorPane class. Gets the current URL being displayed. getRef method for the URL being displayed).

Author: Jujas Kagakree
Country: Iraq
Language: English (Spanish)
Genre: Spiritual
Published (Last): 5 November 2010
Pages: 177
PDF File Size: 20.58 Mb
ePub File Size: 18.14 Mb
ISBN: 813-4-34141-831-8
Downloads: 85290
Price: Free* [*Free Regsitration Required]
Uploader: Gogore

I figured it out. Here we list the facts again and provide a bit more detail.

I don’t know how to pass the path of the page in a platform independent dsplay. The following code shows how this can be done: This method will cause setDocument to be called on behalf of the caller to ensure integrity of the internal state.

The code uses the default constructor to create the editor pane, then calls setEditable false so the jeditorpne cannot edit the text. If there is jedihorpane selection this amounts to an insert of the given text.

Everything I’ve tried just gives me an empty JEditorPane everytime. If you want to specify relative path to the image. A new AccessibleJEditorPane instance is created if necessary. For more information see Swing’s Threading Policy. Gets the current URL being displayed. Once a prototype EditorKit instance is successfully located, it is cloned and the clone is returned.


This can be reimplemented to do useful things like fetch the stream from a cache, monitor the progress of the stream, etc. Here is the complete code which I am using. Here is the complete code: If the URL contains and reference location, the location will be scrolled to by calling the scrollToReference method.

Fetches the currently installed kit for handling content. Two Swing classes support styled text: It will also be fired on the event-dispatch thread.

Images are not scaled correctly in JEditorPane

Otherwise it calls the superclass method which loads the model as plain text. Could you please tell me how you define the String page here? If you want unstyled text, use a text area instead. Returns the preferred size for the JEditorPane.

Using a JEditorPane to display a web page

This method is expected to have the the side effect of establishing the content type, and therefore setting the appropriate EditorKit to use for loading the stream. The class will be dynamically loaded later when actually needed, and can be safely changed before attempted uses to avoid loading unwanted classes.


Here is the code from the TextSamplerDemo example that creates and initializes a text pane. Sets the current URL being displayed. This method can be reimplemented to use some other kind of type registry.

In order to use editor panes and text panes, you need to understand the text system, which is described in Text Component Features. The prototype EditorKit will be loaded with Class. Sets the type of content that this editor handles. The replacement text will have the attributes currently defined for input. jeidtorpane

Using a JEditorPane to display a web page

Both of those assumptions can be violated and cause undesirable results. I got it at last. Returns true if a viewport should always force the width of this Scrollable to match the width of the viewport.