Posted By

alexedy on 03/07/13


Tagged

java browser simple


Versions (?)

Basic browser in java fx


 / Published in: Java
 

don't forget to add jfxrt.jar to class path

  1. package main;
  2.  
  3. import javafx.application.Application;
  4. import javafx.scene.Scene;
  5. import javafx.scene.layout.StackPane;
  6. import javafx.scene.web.WebEngine;
  7. import javafx.scene.web.WebView;
  8. import javafx.stage.Stage;
  9.  
  10. /**
  11. *
  12. * @web http://java-buddy.blogspot.com/
  13. */
  14. public class Request extends Application {
  15.  
  16. /**
  17.   * @param args the command line arguments
  18.   */
  19. public static void main(String[] args) {
  20. launch(args);
  21. }
  22.  
  23. @Override
  24. public void start(Stage primaryStage) {
  25. primaryStage.setTitle("facebook.com");
  26.  
  27. WebView myBrowser = new WebView();
  28. WebEngine myWebEngine = myBrowser.getEngine();
  29. myWebEngine.load("https://google.com");
  30.  
  31. StackPane root = new StackPane();
  32. root.getChildren().add(myBrowser);
  33. primaryStage.setScene(new Scene(root, 640, 480));
  34. primaryStage.show();
  35. }
  36. }

Report this snippet  

You need to login to post a comment.