- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to display a webpage in JEditorPane
Use the setPage() method of the JEditorPane to display a webpage:
JEditorPane editorPane = new JEditorPane(); editorPane.setPage("https://www.tutorialspoint.com");
The following is an example to display a webpage in JEditorPane:
Example
import java.io.IOException; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo { public static void main(String[] args) { JEditorPane editorPane = new JEditorPane(); try { editorPane.setPage("https://www.tutorialspoint.com"); } catch (IOException e) { editorPane.setContentType("text/html"); editorPane.setText("<html>Connection issues!</html>"); } JScrollPane pane = new JScrollPane(editorPane); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(pane); frame.setSize(500, 300); frame.setVisible(true); } }
Output
- Related Articles
- How to change font size with HTML in Java Swing JEditorPane?
- Download webpage in Java
- What are the differences between a JTextPane and a JEditorPane in Java?
- How to scroll down a webpage in selenium using Java?
- Java Program to Display Factors of a Number
- How to display multiple outputs on an HTML webpage using PowerShell?
- Java Program to display 5 different cards in a CardLayout
- Java program to display English alphabets
- Java Program to display printable characters
- Java Program to Display Fibonacci Series
- Java Program to display the contents in JTextArea
- Java Program to display computer time in milliseconds
- Java Program to display Bit manipulation in Integer
- Java Program to Display Alphabets (A to Z) using loop
- Java Program to display only vertical grid lines in a JTable

Advertisements