source file name: EditorPaneDemo1.java
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
class EditorPaneDemo1 extends JFrame
{
JEditorPane ep;
public EditorPaneDemo1()
{
ep = new JEditorPane();
JScrollPane sp=new JScrollPane(ep);
add(sp, BorderLayout.CENTER);
}
public void link(String urlstr)
{
try {
URL url = new URL(urlstr);
ep.setPage(url);
}
catch (IOException e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args)
{
EditorPaneDemo1 f=new EditorPaneDemo1();
f.setTitle("Editor Pane Program");
f.setSize(700, 500);
f.setVisible(true);
f.link("https://sjnprogramming.blogspot.com/");
}
}
output:
0 Comments
Post a Comment