Thursday 25 February 2016

Create web browser with JavaFX 2.0 WebView

JavaFX 2.0 provide WebView, a full function web browser based on WebKit, an open source web browser engine. It supports Cascading Style Sheets (CSS), JavaScript, Document Object Model (DOM), and HTML5 features of rendering canvas and timed media playback.

 /*  
 * To change this template, choose Tools | Templates  
 * and open the template in the editor.  
 */  
 package javafx_webview;  
 import javafx.application.Application;  
 import javafx.scene.Scene;  
 import javafx.scene.layout.StackPane;  
 import javafx.scene.web.WebEngine;  
 import javafx.scene.web.WebView;  
 import javafx.stage.Stage;  
 /**  
 *  
 * @web https://java-tech-world.blogspot.com  
 */  
 public class JavaFX_Browser extends Application {  
  /**  
   * @param args the command line arguments  
   */  
  public static void main(String[] args) {  
    launch(args);  
  }  
  @Override  
  public void start(Stage primaryStage) {  
    primaryStage.setTitle("https://java-tech-world.blogspot.com/");  
    WebView myBrowser = new WebView();  
    WebEngine myWebEngine = myBrowser.getEngine();  
    myWebEngine.load("https://java-tech-world.blogspot.com/");  
    StackPane root = new StackPane();  
    root.getChildren().add(myBrowser);  
    primaryStage.setScene(new Scene(root, 640, 480));  
    primaryStage.show();  
  }  
 }  

No comments:

Post a Comment