import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class HelloWorldApplication extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
webEngine.load( getClass().getResource("/helloWorld.html").toString() );
Scene scene = new Scene(webView,600,600);
primaryStage.setScene(scene);
primaryStage.setTitle("Hello World");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Now you can run the main method using your favorite IDE, and will show the content of helloWorld.html as below.
| Hello World JavaFX |
Join the discussion
We welcome thoughtful feedback and questions.
Sign in to comment
Use your account to join the conversation, or create one in seconds.
Log in to your account
Create your reader account
Commenting as