import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.io.IOException;
public class JavaExampleEditorPaneUrlInSwing extends JFrame
{
JEditorPane EdtrPn = new JEditorPane();
public JavaExampleEditorPaneUrlInSwing()
{
super("Editor Pane Example URL In Java Swing");
Container Cntnr = getContentPane();
EdtrPn.setEditable(false);
String URLStrng = "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"page2.html";
try
{
EdtrPn.setPage(URLStrng);
}
catch(IOException e) {}
EdtrPn.addHyperlinkListener(new HyperlinkListener()
{
public void hyperlinkUpdate(HyperlinkEvent e1)
{
try
{
EdtrPn.setPage(e1.getURL());
}
catch(IOException e2) {}
}
});
Cntnr.add(EdtrPn);
}
public static void main(String aa[])
{
final JFrame Frm = new JavaExampleEditorPaneUrlInSwing();
Frm.setBounds(110,110,310,310);
Frm.setVisible(true);
Frm.setBackground(Color.white);
Frm.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
Frm.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent ee)
{
System.exit(0);
}
});
}
}