Java Web Browser Component introduction

Source: Internet
Author: User

Introduction: Using Java to develop client applications sometimes requires the use of browser components, this article describes four ways to use browsers in the Java user interface, and compares their strengths and weaknesses to make it easier for Java developers to choose between the actual development process.

Objective

When using Java to develop client programs, it is sometimes necessary to use a Web browser component in the interface to display a section of HTML or a specific URL. This article describes four ways to use the browser component in the interface, give the code for the sample, and analyze the pros and weaknesses of each method to make it easier for Java developers to choose from their own needs in the actual development process.

Implementation in JDK-JEditorPane

Swing is a toolkit for developing a graphical user interface for Java applications, based on the Abstract Window Toolkit (AWT), which enables Cross-platform applications to use any pluggable façade style, and it is a lightweight (light-weight) component with no local code. Does not depend on the support of the operating system, which is the biggest difference from the AWT component.

In Swing, one component is JEditorPane, which is a text component that can edit arbitrary content. This class uses Editorkit to implement its operations, and it can effectively transform its type into the appropriate text editor type for the various content given to it. The content type of the editor at any given time is determined by the Editorkit that are currently installed.

By default, JEditorPane supports the following content types:

Text/plain

The contents of plain text, the toolkit used in this case is an extension of Defaulteditorkit, which produces a plain text view with newline.

Text/html

HTML text, in which case the toolkit used is javax.swing.text.html.HTMLEditorKit, which supports HTML3.2.

Text/rtf

Rich Text, the toolkit used in this case is Class Javax.swing.text.rtf.RTFEditorKit, which provides limited support for a variety of text formats (Rich Text format).

Common methods of JEditorPane

JEditorPane ()

Create a new JEditorPane object

JEditorPane (String URL)

Creates a jeditorpane based on a string containing a URL specification

JEditorPane (String type,string text)

Creates a jediorpane that has been initialized to a given file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.