Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package fxdemo6;
  7.  
  8. import javafx.application.Application;
  9. import javafx.event.ActionEvent;
  10. import javafx.scene.Scene;
  11. import javafx.scene.control.Button;
  12. import javafx.scene.layout.Pane;
  13. import javafx.scene.layout.VBox;
  14. import javafx.scene.web.WebEngine;
  15. import javafx.scene.web.WebView;
  16. import javafx.stage.Stage;
  17.  
  18. public class FXDemo6 extends Application {
  19.    
  20.     WebEngine wEngine;
  21.     //
  22.     public static void main(String[] args) {
  23.         // TODO code application logic here          
  24.         launch(args);
  25.     }
  26.     //  FlowPane pane = new FlowPane();      
  27.     private Pane createPane(){        
  28.         Pane pane = new VBox();          
  29.         // создаем элементы управления
  30.         Button btn1 = new Button("Show");        
  31.         btn1.setOnAction(this::onClickButtonAction);
  32.         pane.getChildren().add(btn1);        
  33.         // WebView -
  34.         WebView browser = new WebView();
  35.         wEngine = browser.getEngine();
  36.         // добавляем браузер в панель
  37.         pane.getChildren().add(browser);  
  38.        
  39.         return pane;
  40.     }    
  41.     private void onClickButtonAction(ActionEvent t) {
  42.         System.out.println("onClickButtonAction>>");
  43.        
  44.         wEngine.load("https://oracle.com");
  45.         System.out.println("<<");
  46.     }
  47.     @Override
  48.     public void start(Stage stage) throws Exception {
  49.         //
  50.         System.out.println("FXDemo6.start>>");
  51.         // создаем сцену (объект типа Scene)
  52.         Scene scene = new Scene(createPane(), 1024, 680);                  
  53.         // заголовок окна (подмостка)
  54.         stage.setTitle("FXDemo6 - WebView!!!");        
  55.         stage.setScene(scene);
  56.         // показ окна на экране
  57.         stage.show();
  58.     }      
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement