/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javafxef;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.concurrent.Worker;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebHistory;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import netscape.javascript.JSObject;
import org.w3c.dom.Document;
import java.util.Date;
import java.util.Iterator;
import javafx.geometry.Rectangle2D;
import javafx.stage.Screen;
public class WebViewExample extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX WebView Example");
WebView webView = new WebView();
//webView.setZoom(2.25);
//webView.setFontScale(1.25);
//webView.setContextMenuEnabled(false);
WebEngine webEngine = webView.getEngine();
//webEngine.setUserStyleSheetLocation("assets/webview/stylesheet.css");
webEngine.load("https://wowpress.co.kr");
//webEngine.loadContent("<!DOCTYPE html><html><body>Hello World!</body></html>", "text/html");
webEngine.setUserAgent("MyApp Web Browser 1.0");
//webEngine.reload();
//historyExamples(webEngine);
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
VBox vBox = new VBox(webView);
vBox.autosize();
// Scene scene = new Scene(vBox, 960, 600);
//Scene scene = new Scene(vBox, bounds.getWidth(), bounds.getHeight());
//Scene scene = new Scene(vBox, bounds.getHeight(),bounds.getWidth());
Scene scene = new Scene(vBox, 1960, 1200);
primaryStage.setScene(scene);
primaryStage.setMaximized(true);
primaryStage.setFullScreen(true);
primaryStage.show();
}
private void historyExamples(WebEngine webEngine) {
WebHistory history = webEngine.getHistory();
ObservableList<WebHistory.Entry> entries = history.getEntries();
Iterator<WebHistory.Entry> iterator = entries.iterator();
while(iterator.hasNext()){
WebHistory.Entry entry = iterator.next();
}
for(WebHistory.Entry entry : entries){
//do something with the entry
String url = entry.getUrl();
String title = entry.getTitle();
Date lastVisitedDate = entry.getLastVisitedDate();
}
history.go(1);
history.go(-1);
int currentIndex = history.getCurrentIndex();
}
}