-1

Possible Duplicate:
display HTML page the same in Java forms

I want to display a HTML file in Java Swing application. I am using the following code, it displays the specified URL web page but I want to display a static HTML page stored on a particular location eg D:\\new folder\test.html. How is it possible? Is there any other useful tool in Swing than JEditorpane?

I am using the following code

try {
    URL url= new URL("http://www.lawcrux.com");
    htmlPane = new JEditorPane();
    htmlPane.setContentType("text/html");
    htmlPane.setPage(url);
    htmlPane.addHyperlinkListener(this);

    JScrollPane jsp= new JScrollPane(htmlPane);

    cp.add(jsp);
    jsp.setBounds(750, 50, 600, 600);  
} catch(Exception ex) {} 
Community
  • 1
  • 1
adesh
  • 1,157
  • 3
  • 18
  • 28
  • 1
    *"I want to display a static HTML page stored on a particular location eg D:\\new folder\test.html. How is it possible?"* As an aside, the answer to this was provided in the last 2 lines of [this answer](http://stackoverflow.com/a/12540795/418556) on one of your **duplicate** threads under your **split** personality. *If you don't intend reading the answers, please stop asking the questions.* :-/ – Andrew Thompson Sep 22 '12 at 07:43

1 Answers1

2

Try this:

File htmlFile = new File("c:/web.html");
htmlPane.setPage(htmlFile.toURI().toURL());
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417