Java Code Examples for javafx.scene.web.WebView#getEngine()

The following examples show how to use javafx.scene.web.WebView#getEngine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexService.java    From xJavaFxTool-spring with Apache License 2.0 6 votes vote down vote up
/**
 * @Title: addWebView
 * @Description: 添加WebView视图
 */
public void addWebView(String title, String url, String iconPath) {
    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    if (url.startsWith("http")) {
        webEngine.load(url);
    } else {
        webEngine.load(IndexController.class.getResource(url).toExternalForm());
    }
    if (indexController.getSingleWindowBootCheckBox().isSelected()) {
        JavaFxViewUtil.getNewStage(title, iconPath, new BorderPane(browser));
        return;
    }
    Tab tab = new Tab(title);
    if (StringUtils.isNotEmpty(iconPath)) {
        ImageView imageView = new ImageView(new Image(iconPath));
        imageView.setFitHeight(18);
        imageView.setFitWidth(18);
        tab.setGraphic(imageView);
    }
    tab.setContent(browser);
    indexController.getTabPaneMain().getTabs().add(tab);
    indexController.getTabPaneMain().getSelectionModel().select(tab);
}
 
Example 2
Source File: VirtualCursor.java    From haxademic with MIT License 6 votes vote down vote up
public Browser(int w, int h) {
			this.w = w;
			this.h = h;
			thiss = this;
			webView = new WebView();
			webEngine = webView.getEngine();
			getChildren().add(webView);
			//apply the styles
//			getStyleClass().add("browser");
			// load the web page
			
			// load page & attach js bridge to call up to java
			P.println(webEngine.getUserAgent());
			webEngine.load("http://192.168.1.3:3333/touchless/sdk/javascript/#mode=kiosk&customerId=hovercraft&deviceId=1234567890");

			P.out("Adding js callback!");
			JSObject win = (JSObject) webEngine.executeScript("window");
			win.setMember("native", thiss);
		}
 
Example 3
Source File: HtmlWebView.java    From Learn-Java-12-Programming with MIT License 6 votes vote down vote up
public void start8(Stage primaryStage) {
    try {
        Text txt = new Text("Below is the embedded HTML:");

        WebView wv = new WebView();
        WebEngine we = wv.getEngine();
        String html = "<html><center><h2>Hello, world!</h2></center></html>";
        we.loadContent(html, "text/html");

        VBox vb = new VBox(txt, wv);
        vb.setSpacing(10);
        vb.setAlignment(Pos.CENTER);
        vb.setPadding(new Insets(10, 10, 10, 10));

        Scene scene = new Scene(vb, 300, 120);

        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX with embedded HTML");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example 4
Source File: SamplePage.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
protected WebView getWebView() {
	if (engine == null) {
		webView = new WebView();
		webView.setContextMenuEnabled(false);
		engine = webView.getEngine();
	}
	return webView;
}
 
Example 5
Source File: ArrayTester.java    From GMapsFX with Apache License 2.0 5 votes vote down vote up
@Override
public void start(final Stage stage) throws Exception {
    
    webview = new WebView();
    webengine = new JavaFxWebEngine(webview.getEngine());
    JavascriptRuntime.setDefaultWebEngine( webengine );
    
    BorderPane bp = new BorderPane();
    bp.setCenter(webview);
    
    webengine.getLoadWorker().stateProperty().addListener(
            new ChangeListener<Worker.State>() {
                public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
                    if (newState == Worker.State.SUCCEEDED) {
                        runTests();
                        //Platform.exit();
                    }
                }
            });
    webengine.load(getClass().getResource("/com/lynden/gmapsfx/html/arrays.html").toExternalForm());
    
    Scene scene = new Scene(bp, 600, 600);
    
    stage.setScene(scene);
    stage.show();
    
}
 
Example 6
Source File: GoogleLoginDialog.java    From zest-writer with GNU General Public License v3.0 5 votes vote down vote up
public GoogleLoginDialog(LoginDialog parent) {
       super();
	this.setTitle(Configuration.getBundle().getString("ui.dialog.auth.google.title"));

       final WebView browser = new WebView();
       final WebEngine webEngine = browser.getEngine();

       ScrollPane scrollPane = new ScrollPane();
       scrollPane.setContent(browser);
       CookieManager manager = new CookieManager();
       CookieHandler.setDefault(manager);
       webEngine.setJavaScriptEnabled(false);

       this.getDialogPane().setContent(scrollPane);
       this.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL);

       webEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> {
           if(newState == State.RUNNING) {
               if(webEngine.getLocation().contains("accounts.google.com/ServiceLoginAuth")) {
                   scrollPane.setVisible(false);
               }
           }
           if(newState == State.SUCCEEDED) {
               if("https://zestedesavoir.com/".equals(webEngine.getLocation())) {
                   Element elementary = webEngine.getDocument().getDocumentElement();
                   Element logbox = getLogBox(elementary);
                   String pseudo = getPseudo(logbox);
                   String id = getId(logbox);
                   MainApp.getZdsutils().authToGoogle(manager.getCookieStore().getCookies(), pseudo, id);
                   getThis().close();
                   parent.close();
               } else {
                   if(webEngine.getLocation().contains("accounts.google.com/ServiceLoginAuth")) {
                       scrollPane.setVisible(true);
                   }
               }
           }
       });
       webEngine.load("https://zestedesavoir.com/login/google-oauth2/");
}
 
Example 7
Source File: WebViewSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public WebViewSample() {
    WebView webView = new WebView();
    
    final WebEngine webEngine = webView.getEngine();
    webEngine.load(DEFAULT_URL);
    
    final TextField locationField = new TextField(DEFAULT_URL);
    webEngine.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            webEngine.load(locationField.getText().startsWith("http://") 
                    ? locationField.getText() 
                    : "http://" + locationField.getText());
        }
    };
    locationField.setOnAction(goAction);
    
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    goButton.setOnAction(goAction);
    
    // Layout logic
    HBox hBox = new HBox(5);
    hBox.getChildren().setAll(locationField, goButton);
    HBox.setHgrow(locationField, Priority.ALWAYS);
    
    VBox vBox = new VBox(5);
    vBox.getChildren().setAll(hBox, webView);
    VBox.setVgrow(webView, Priority.ALWAYS);

    getChildren().add(vBox);
}
 
Example 8
Source File: HyperlinkWebViewSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    VBox vbox = new VBox();
    Scene scene = new Scene(vbox);
    stage.setTitle("Hyperlink Sample");
    stage.setWidth(570);
    stage.setHeight(550);

    selectedImage.setLayoutX(100);
    selectedImage.setLayoutY(10);

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    for (int i = 0; i < captions.length; i++) {
        final Hyperlink hpl = hpls[i] = new Hyperlink(captions[i]);
        final Image image = images[i] = new Image(getClass().getResourceAsStream(imageFiles[i]));
        hpl.setGraphic(new ImageView(image));
        hpl.setFont(Font.font("Arial", 14));
        final String url = urls[i];

        hpl.setOnAction((ActionEvent e) -> {
            webEngine.load(url);
        });
    }

    HBox hbox = new HBox();
    hbox.setAlignment(Pos.BASELINE_CENTER);
    hbox.getChildren().addAll(hpls);
    vbox.getChildren().addAll(hbox, browser);
    VBox.setVgrow(browser, Priority.ALWAYS);

    stage.setScene(scene);
    stage.show();
}
 
Example 9
Source File: HtmlWebView.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
public void start10(Stage primaryStage) {

        Text txt = new Text("Enjoy searching the Web!");

        WebView wv = new WebView();
        WebEngine we = wv.getEngine();
        we.load("http://www.google.com");
        //wv.setZoom(1.5);

/*
        WebHistory history = we.getHistory();
        ObservableList<WebHistory.Entry> entries = history.getEntries();
        for(WebHistory.Entry entry: entries){
            String url = entry.getUrl();
            String title = entry.getTitle();
            Date date = entry.getLastVisitedDate();
        }
*/

        VBox vb = new VBox(txt, wv);
        vb.setSpacing(20);
        vb.setAlignment(Pos.CENTER);
        vb.setStyle("-fx-font-size: 20px;-fx-background-color: lightblue;");
        vb.setPadding(new Insets(10, 10, 10, 10));

        Scene scene = new Scene(vb,750,500);
        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX with the window to another server");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();
    }
 
Example 10
Source File: OrsonChartsFXDemo.java    From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
   
    TabPane tabPane = new TabPane();
    Tab tab1 = new Tab();
    tab1.setText("Demos");
    tab1.setClosable(false);
    
    SplitPane sp = new SplitPane();
    final StackPane sp1 = new StackPane();
    sp1.getChildren().add(createTreeView());
    final BorderPane sp2 = new BorderPane();
    sp2.setCenter(createChartPane());
 
    sp.getItems().addAll(sp1, sp2);
    sp.setDividerPositions(0.3f, 0.6f);
    tab1.setContent(sp);
    tabPane.getTabs().add(tab1);        
 
    Tab tab2 = new Tab();
    tab2.setText("About");
    tab2.setClosable(false);
    
    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    webEngine.load(getClass().getResource("/org/jfree/chart3d/fx/demo/about.html").toString());
    tab2.setContent(browser);
    tabPane.getTabs().add(tab2);        

    Scene scene = new Scene(tabPane, 1024, 768);
    stage.setScene(scene);
    stage.setTitle("Orson Charts JavaFX Demo");
    stage.show();
}
 
Example 11
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(650);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final HTMLEditor htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(245);
    htmlEditor.setHtmlText(INITIAL_TEXT);

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setStyle("-fx-background-color: white");
    scrollPane.setContent(browser);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Load Content in Browser");
    root.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction((ActionEvent arg0) -> {
        webEngine.loadContent(htmlEditor.getHtmlText());
    });

    root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}
 
Example 12
Source File: WebViewSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public WebViewSample() {
    WebView webView = new WebView();
    
    final WebEngine webEngine = webView.getEngine();
    webEngine.load(DEFAULT_URL);
    
    final TextField locationField = new TextField(DEFAULT_URL);
    webEngine.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            webEngine.load(locationField.getText().startsWith("http://") 
                    ? locationField.getText() 
                    : "http://" + locationField.getText());
        }
    };
    locationField.setOnAction(goAction);
    
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    goButton.setOnAction(goAction);
    
    // Layout logic
    HBox hBox = new HBox(5);
    hBox.getChildren().setAll(locationField, goButton);
    HBox.setHgrow(locationField, Priority.ALWAYS);
    
    VBox vBox = new VBox(5);
    vBox.getChildren().setAll(hBox, webView);
    VBox.setVgrow(webView, Priority.ALWAYS);

    getChildren().add(vBox);
}
 
Example 13
Source File: TestTranparentApps.java    From oim-fx with MIT License 5 votes vote down vote up
public WebPage(Stage mainstage) {
	webview = new WebView();
	webengine = webview.getEngine();

	Scene scene = new Scene(webview);
	scene.setFill(null);

	mainstage.setScene(scene);
	mainstage.initStyle(StageStyle.TRANSPARENT);
	mainstage.setWidth(700);
	mainstage.setHeight(100);

	webengine.documentProperty().addListener(new DocListener());
	webengine.loadContent("<body style='background : rgba(0,0,0,0);font-size: 70px;text-align:center;'>Test Transparent</body>");
}
 
Example 14
Source File: AboutController.java    From Library-Assistant with Apache License 2.0 5 votes vote down vote up
private void handleWebpageLoadException(String url) {
    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    webEngine.load(url);
    Stage stage = new Stage();
    Scene scene = new Scene(new StackPane(browser));
    stage.setScene(scene);
    stage.setTitle("Genuine Coder");
    stage.show();
    LibraryAssistantUtil.setStageIcon(stage);
}
 
Example 15
Source File: Browser.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public Stage startWebTool() {

	    Stage webStage = new Stage();
	    webStage.setTitle("Mars Simulation Project - Online Tool");
	    webStage.initModality(Modality.APPLICATION_MODAL);

	    final WebView webView = new WebView();
	    final WebEngine webEngine = webView.getEngine();

	    ScrollPane scrollPane = new ScrollPane();
	    scrollPane.setFitToWidth(true);
	    scrollPane.setContent(webView);

	    webEngine.getLoadWorker().stateProperty()
	        .addListener(new ChangeListener<State>() {
	          //@Override
	          public void changed(@SuppressWarnings("rawtypes") ObservableValue ov, State oldState, State newState) {
	            if (newState == Worker.State.SUCCEEDED) {
	            	webStage.setTitle(webEngine.getLocation());
	            }
	          }
	        });

	    webEngine.load("http://mars-sim.sourceforge.net/#development");
	    //webEngine.load("http://jquerymy.com/");

	    Scene webScene = new Scene(scrollPane);
	    webStage.setScene(webScene);

	    return webStage;
	}
 
Example 16
Source File: JXBrowser.java    From gdx-facebook with Apache License 2.0 4 votes vote down vote up
@Override
    public void start(Stage pStage) throws Exception {

        Platform.setImplicitExit(false);

        primaryStage = pStage;
        primaryStage.setAlwaysOnTop(true);
        primaryStage.setTitle("Facebook Sign in");

        webView = new WebView();

        CookieHandler.setDefault(new CookieManager());

        webEngine = webView.getEngine();

//        webEngine.getLoadWorker().stateProperty().addListener(
//                new ChangeListener<Worker.State>() {
//                    public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
//                        if (webEngine.getLoadWorker().getException() != null && newState == Worker.State.FAILED){
//                            System.out.println(webEngine.getLoadWorker().getException().toString());
//                        }
//                    }
//                });

        webEngine.load(url);
        webEngine.locationProperty().addListener(new ChangeListener<String>() {

            @Override
            public void changed(ObservableValue<? extends String> arg0, String oldLocation, String newLocation) {

                /**
                 *  Return to DesktopGDXFacebook when we receive a error or successful login in URL change.
                 *  (not unit tested)
                 * */
                if (Utils.isValidSuccessfulSignInURL(newLocation) || Utils.isValidErrorSignInURL(newLocation)) {
                    callbackHandler.handleURL(newLocation);
                    closeBrowser();
                }
            }

        });


        stackPane = new StackPane();
        stackPane.getChildren().add(webView);

        rootScene = new Scene(stackPane);

        primaryStage.setScene(rootScene);
        primaryStage.show();


        primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            public void handle(WindowEvent we) {
                JXBrowser.callbackHandler.handleCancel();
            }
        });
    }
 
Example 17
Source File: WebModule.java    From WorkbenchFX with Apache License 2.0 4 votes vote down vote up
public WebModule(String name, MaterialDesignIcon icon, String url) {
  super(name, icon);
  this.url = url;

  // setup webview
  browser = new WebView();
  webEngine = browser.getEngine();

  // workaround since HTTP headers related to CORS, are restricted, see: https://bugs.openjdk.java.net/browse/JDK-8096797
  System.setProperty("sun.net.http.allowRestrictedHeaders", "true");

  // setup textfield for URL
  browserUrl = new TextField("Loading...");
  HBox.setHgrow(browserUrl, Priority.ALWAYS);
  browserUrl.setPrefColumnCount(Integer.MAX_VALUE); // make sure textfield takes up rest of space
  browserUrl.setEditable(false);

  // setup toolbar
  ToolbarItem back = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.CHEVRON_LEFT),
      event -> webEngine.executeScript("history.back()"));
  ToolbarItem forward = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.CHEVRON_RIGHT),
      event -> webEngine.executeScript("history.forward()"));
  ToolbarItem home = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.HOME),
      event -> webEngine.load(url));
  ToolbarItem reload = new ToolbarItem(new MaterialDesignIconView(MaterialDesignIcon.REFRESH),
      event -> webEngine.reload());
  getToolbarControlsLeft().addAll(back, forward, home, reload, new ToolbarItem(browserUrl));

  ToolbarItem increaseSize = new ToolbarItem(new Group(increaseFontIcon),
      event -> browser.setFontScale(browser.getFontScale() + FONT_SCALE_INCREMENT));
  ToolbarItem decreaseSize = new ToolbarItem(new Group(decreaseFontIcon),
      event -> browser.setFontScale(browser.getFontScale() - FONT_SCALE_INCREMENT));
  getToolbarControlsRight().addAll(increaseSize, decreaseSize);

  // update textfield with url every time the url of the webview changes
  webEngine.documentProperty().addListener(
      observable -> {
        Document document = webEngine.getDocument();
        if (!Objects.isNull(document) &&
            !Strings.isNullOrEmpty(document.getDocumentURI())) {
          browserUrl.setText(document.getDocumentURI());
        }
      });
}
 
Example 18
Source File: O365InteractiveAuthenticatorFrame.java    From davmail with GNU General Public License v2.0 4 votes vote down vote up
private void initFX(final JFXPanel fxPanel, final String url, final String redirectUri) {
    WebView webView = new WebView();
    final WebEngine webViewEngine = webView.getEngine();

    final ProgressBar loadProgress = new ProgressBar();
    loadProgress.progressProperty().bind(webViewEngine.getLoadWorker().progressProperty());

    StackPane hBox = new StackPane();
    hBox.getChildren().setAll(webView, loadProgress);
    Scene scene = new Scene(hBox);
    fxPanel.setScene(scene);

    webViewEngine.setOnAlert(stringWebEvent -> SwingUtilities.invokeLater(() -> {
        String message = stringWebEvent.getData();
        JOptionPane.showMessageDialog(O365InteractiveAuthenticatorFrame.this, message);
    }));
    webViewEngine.setOnError(event -> LOGGER.error(event.getMessage()));


    webViewEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            loadProgress.setVisible(false);
            location = webViewEngine.getLocation();
            updateTitleAndFocus(location);
            LOGGER.debug("Webview location: " + location);
            // override console.log
            O365InteractiveJSLogger.register(webViewEngine);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(dumpDocument(webViewEngine.getDocument()));
            }
            if (location.startsWith(redirectUri)) {
                LOGGER.debug("Location starts with redirectUri, check code");

                authenticator.isAuthenticated = location.contains("code=") && location.contains("&session_state=");
                if (!authenticator.isAuthenticated && location.contains("error=")) {
                    authenticator.errorCode = location.substring(location.indexOf("error="));
                }
                if (authenticator.isAuthenticated) {
                    LOGGER.debug("Authenticated location: " + location);
                    String code = location.substring(location.indexOf("code=") + 5, location.indexOf("&session_state="));
                    String sessionState = location.substring(location.lastIndexOf('='));

                    LOGGER.debug("Authentication Code: " + code);
                    LOGGER.debug("Authentication session state: " + sessionState);
                    authenticator.code = code;
                }
                close();
            }
        } else if (newState == Worker.State.FAILED) {
            Throwable e = webViewEngine.getLoadWorker().getException();
            if (e != null) {
                handleError(e);
            }
            close();
        }

    });
    webViewEngine.load(url);
}
 
Example 19
Source File: MainViewImpl.java    From oim-fx with MIT License 4 votes vote down vote up
protected void initComponent() {

		Image normalImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_contacts_normal.png");
		Image hoverImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_contacts_hover.png");
		Image selectedImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_contacts_selected.png");

		mainFrame.addTab(normalImage, hoverImage, selectedImage, userRoot);

		normalImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_group_normal.png");
		hoverImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_group_hover.png");
		selectedImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_group_selected.png");

		mainFrame.addTab(normalImage, hoverImage, selectedImage, groupRoot);

		normalImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_last_normal.png");
		hoverImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_last_hover.png");
		selectedImage = ImageBox.getImageClassPath("/resources/main/images/panel/icon_last_selected.png");

		mainFrame.addTab(normalImage, hoverImage, selectedImage, lastRoot);

		normalImage = ImageBox.getImageClassPath("/resources/main/images/panel/qzone_normal.png");
		hoverImage = ImageBox.getImageClassPath("/resources/main/images/panel/qzone_hover.png");
		selectedImage = ImageBox.getImageClassPath("/resources/main/images/panel/qzone_selected.png");

		VBox website = new VBox();
		WebView websiteWebView = new WebView();
		WebEngine websiteWebEngine = websiteWebView.getEngine();
		websiteWebEngine.load("http://www.oimismine.com/");
		website.getChildren().add(websiteWebView);

		mainFrame.addTab(normalImage, hoverImage, selectedImage, website);

		normalImage = ImageBox.getImageClassPath("/resources/main/images/panel/main_panel_tab_inco_normal.png");
		hoverImage = ImageBox.getImageClassPath("/resources/main/images/panel/main_panel_tab_inco_hover.png");
		selectedImage = ImageBox.getImageClassPath("/resources/main/images/panel/main_panel_tab_inco_selected.png");

		VBox blog = new VBox();
		WebView blogWebView = new WebView();
		WebEngine blogWebEngine = blogWebView.getEngine();
		blogWebEngine.load("https://my.oschina.net/onlyxiahui/blog/759149");
		blog.getChildren().add(blogWebView);
		// blog.setStyle("-fx-background-color:rgba(215, 165, 230, 1)");
		mainFrame.addTab(normalImage, hoverImage, selectedImage, blog);

		normalImage = ImageBox.getImageClassPath("/resources/main/images/panel/main_panel_phone_inco_normal.png");
		hoverImage = ImageBox.getImageClassPath("/resources/main/images/panel/main_panel_phone_inco_hover.png");
		selectedImage = ImageBox.getImageClassPath("/resources/main/images/panel/main_panel_phone_inco_selected.png");

		VBox git = new VBox();

		WebView gitWebView = new WebView();
		WebEngine gitWebEngine = gitWebView.getEngine();
		gitWebEngine.load("https://gitee.com/onlysoftware/oim-fx");

		git.getChildren().add(gitWebView);
		// git.setStyle("-fx-background-color:rgba(112, 245, 86, 1);");
		mainFrame.addTab(normalImage, hoverImage, selectedImage, git);
	}
 
Example 20
Source File: FxWebViewExample1.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage stage)
{
	// Create the WebView
	WebView webView = new WebView();

	// Create the WebEngine
	final WebEngine webEngine = webView.getEngine();

	// LOad the Start-Page
	webEngine.load("http://www.oracle.com");

	// Update the stage title when a new web page title is available
	webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>()
	{
           public void changed(ObservableValue<? extends State> ov, State oldState, State newState)
           {
               if (newState == State.SUCCEEDED)
               {
                   //stage.setTitle(webEngine.getLocation());
               	stage.setTitle(webEngine.getTitle());
               }
           }
       });

	// Create the VBox
	VBox root = new VBox();
	// Add the WebView to the VBox
	root.getChildren().add(webView);

	// Set the Style-properties of the VBox
	root.setStyle("-fx-padding: 10;" +
			"-fx-border-style: solid inside;" +
			"-fx-border-width: 2;" +
			"-fx-border-insets: 5;" +
			"-fx-border-radius: 5;" +
			"-fx-border-color: blue;");

	// Create the Scene
	Scene scene = new Scene(root);
	// Add  the Scene to the Stage
	stage.setScene(scene);
	// Display the Stage
	stage.show();
}