JavaFX: Webview

You have heard of phonegap where you can develop your App in HTML/Javascript and publish it in Apple App store?  This is also called the non native App and judging from the trend, it seems to be getting more and more popular.

The single piece of module that makes it work is the Web View engine found in Java and Objective-C.

Consider the example below.  If my site snapwhere.com is coded in Javascript/HTML, I can have it run on top of Java using just a few lines of code.

package webviewsample;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewSample extends Application {

    @Override
    public void start(Stage stage) {

        stage.setTitle("Snapwhere.com");
        WebView view = new WebView();
        WebEngine engine = view.getEngine();
        engine.load("http://www.snapwhere.com");
        Scene scene = new Scene(view, 400, 600);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

webview1

 

Series Navigation<< JavaFX: Putting drawings into group
JavaFX: Generating grid lines using group >>