2

I am mixing a JavaFX controls to swing application. I want to use WebView Control of JavaFX in Swing application . Can I browse the HTML files stored on the local hard disk of client as I can show with the help of JEditorPane in Java? Web View can display a web page from the internet but can it also browse the local system HTML files.

In WebView I am using the following code.

try
{ 
   final WebView webview = new WebView();
   webview.getEngine().load("http://oracle.com");
}
 catch(Exception ex)
 {
    ex.printStackTrace();
 }

My query is instead of the web page from net how can I give the local HTML file in load method?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
adesh
  • 1,157
  • 3
  • 18
  • 28

1 Answers1

13
File f = new File(..);
// ..
final WebView webview = new WebView();
webview.getEngine().load(f.toURI().toURL().toString());
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • ya its working thanks . Can i add webview or webengine control to the container in swing. – adesh Nov 21 '12 at 05:33
  • 1
    See your follow up question [add webview on swing jframe form](http://stackoverflow.com/questions/13487786/add-web-view-control-on-swing-jframe-form) – jewelsea Nov 21 '12 at 08:05