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: Arashijas Tesida
Country: Belarus
Language: English (Spanish)
Genre: Personal Growth
Published (Last): 15 January 2005
Pages: 88
PDF File Size: 12.27 Mb
ePub File Size: 4.41 Mb
ISBN: 592-6-72725-164-4
Downloads: 55958
Price: Free* [*Free Regsitration Required]
Uploader: Goltizragore

Sign up or log in Sign up using Google. This is implemented to call JTextComponent. I tried to pass a path or a file name, but it always gives me an Invalid URL error.

displaying HTML in a JEditorPane (Swing / AWT / SWT forum at Coderanch)

This is defined to be the type associated with the currently installed EditorKit. Glad I could help! Creates a new JEditorPane. The setPage method can be used to initialize the component from a URL. For more information see Swing’s Threading Policy.

In this case, the page property change event will not be fired by the call displya this method directly, but rather will be fired when the thread doing the loading has finished. The implementation calls the scrollRectToVisible method to accomplish the actual scrolling. EditorKit getEditorKit Fetches the currently installed kit for handling content.

The default varies based on the look and feel; to enable it jjeditorpane the client property with this name to Boolean. NullPointerException – if the type parameter is null See Also: Returns true if a viewport should always force the height of this Scrollable to match the height of the viewport.


If a URL was not specified in the creation of the document, this will return nulland relative URL’s will not be resolved.

Display html string in JEditorPane in Java

Sign up using Email and Password. Instead, a program would use an editor pane to save a document which would then be used to initialize the text pane. Let’s say your project folder structure is as following: Post Your Answer Discard By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and displya policyand that your continued use of the website is subject to these policies.

This is the bound property that establishes the content type of the editor.

[JDK] Images are not scaled correctly in JEditorPane – Java Bug System

However, the top right editor pane illustrates a handy, easy-to-use feature: IOException – as thrown by the stream being used to initialize See Also: If you want unstyled text, use a text area instead. 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.

This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. Examples and practices described in this page don’t take advantage of improvements introduced in later releases. This is mostly convenience method that can be used as an alternative to calling setEditorKit directly.


If this disolay stream was an http connection, redirects will be followed and the resulting URL will be set as the Document. 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.

Images are not scaled correctly in JEditorPane

It definitely works I am using it. 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.

In this case jjeditorpane current EditorKit will be used, and the content type will be expected to be of this type. Here is the complete code: Establishes the default bindings of type to classname.

If you want to specify relative path to the image. The following code shows how this can be done: