本文整理匯總了Java中javafx.scene.web.WebEngine.load方法的典型用法代碼示例。如果您正苦於以下問題:Java WebEngine.load方法的具體用法?Java WebEngine.load怎麽用?Java WebEngine.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.web.WebEngine
的用法示例。
在下文中一共展示了WebEngine.load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: WebViewPane
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
public WebViewPane() {
VBox.setVgrow(this, Priority.ALWAYS);
setMaxWidth(Double.MAX_VALUE);
setMaxHeight(Double.MAX_VALUE);
WebView view = new WebView();
view.setMinSize(500, 400);
view.setPrefSize(500, 400);
final WebEngine eng = view.getEngine();
eng.load("http://www.oracle.com/us/index.html");
final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
locationField.setMaxHeight(Double.MAX_VALUE);
Button goButton = new Button("Go");
goButton.setDefaultButton(true);
EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
"http://" + locationField.getText());
}
};
goButton.setOnAction(goAction);
locationField.setOnAction(goAction);
eng.locationProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
locationField.setText(newValue);
}
});
GridPane grid = new GridPane();
grid.setVgap(5);
grid.setHgap(5);
GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
GridPane.setConstraints(goButton,1,0);
GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
grid.getColumnConstraints().addAll(
new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
);
grid.getChildren().addAll(locationField, goButton, view);
getChildren().add(grid);
}
示例2: WebViewSample
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
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);
}
示例3: initComponents
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
private void initComponents() {
webView.setId("webView");
webView.getEngine().getLoadWorker().stateProperty().addListener(new HyperlinkRedirectListener(webView));
VBox.setVgrow(webView, Priority.ALWAYS);
WebEngine engine = webView.getEngine();
if (blurbInfo.getURL() != null)
engine.load(blurbInfo.getURL().toExternalForm());
else
engine.loadContent(blurbInfo.getHtml());
buttonBar.setId("buttonBar");
buttonBar.setButtonMinWidth(Region.USE_PREF_SIZE);
buttonBar.getButtons().add(okButton);
if (blurbInfo.isCancelNeeded()) {
buttonBar.getButtons().add(cancelButton);
}
okButton.setOnAction((e) -> onOk());
cancelButton.setOnAction((e) -> onCancel());
}
示例4: initComponent
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
private void initComponent() {
webView = new WebView();
String externalForm = ACEEditor.class.getResource("/Ace.html").toExternalForm();
WebEngine engine = webView.getEngine();
engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
@Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
if (newValue != State.SUCCEEDED) {
return;
}
JSObject window = (JSObject) engine.executeScript("window");
window.setMember("java", ACEEditor.this);
engine.executeScript("console.log = function(message)\n" + "{\n" + " java.log(message);\n" + "};");
ACEEditor.this.engine = engine;
setOptions(new JSONObject().put("showLineNumbers", showLinenumbers).put("firstLineNumber", startLineNumber)
.put("overwrite", false));
loadPreferences();
hookKeyBindings();
}
});
engine.load(externalForm);
ToolBarContainer container = ToolBarContainer.createDefaultContainer(Orientation.RIGHT);
if (withToolbar) {
ToolBarPanel toolBarPanel = container.getToolBarPanel();
createToolBars(toolBarPanel);
}
container.setContent(webView);
this.node = container;
}
示例5: start
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
@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("/com/orsoncharts/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();
}
示例6: createChartPane
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
private SplitPane createChartPane() {
CategoryDataset3D dataset = SampleData.createCompanyRevenueDataset();
Chart3D chart = AreaChart3DFXDemo1.createChart(dataset);
Chart3DViewer viewer = new Chart3DViewer(chart);
this.splitter = new SplitPane();
splitter.setOrientation(Orientation.VERTICAL);
final BorderPane borderPane = new BorderPane();
borderPane.setCenter(viewer);
// Bind canvas size to stack pane size.
viewer.prefWidthProperty().bind(borderPane.widthProperty());
viewer.prefHeightProperty().bind(borderPane.heightProperty());
final StackPane sp2 = new StackPane();
this.chartDescription = new WebView();
WebEngine webEngine = chartDescription.getEngine();
webEngine.load(AreaChart3DFXDemo1.class.getResource("AreaChart3DFXDemo1.html").toString());
sp2.getChildren().add(chartDescription);
splitter.getItems().addAll(borderPane, sp2);
splitter.setDividerPositions(0.70f, 0.30f);
return splitter;
}
示例7: createBrowser
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
/**
* @param pane
* @param backButton
* @param forwardButton
*/
public static void createBrowser(final Pane pane, final Button backButton, final Button forwardButton) {
LOGGER.info("Start initialization for a web page");
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
webEngine.load(PREDEFINED_URL_CNN);
browser.setMaxWidth(pane.getWidth());
browser.setMinHeight(pane.getHeight());
pane.getChildren().add(browser);
initControlsFor(webEngine, backButton, forwardButton);
LOGGER.info("Initialization for a web page is done");
}
示例8: initialize
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
private void initialize(WebEngine engine) {
WebConsoleListener.setDefaultListener(new WebConsoleListener() {
@Override
public void messageAdded(WebView webView, String message,
int lineNumber, String sourceId) {
System.out.println("Console: [" + sourceId + ":" + lineNumber
+ "] " + message);
}
});
engine.load(getClass().getResource("ide.html")
.toExternalForm());
}
示例9: initialize
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
/**
* 생성자로 객체생성후 initialize 호출.
*
* @작성자 : KYJ
* @작성일 : 2017. 10. 25.
*/
protected TinymceDeligator initialize() {
try {
WebEngine engine = webview.getEngine();
// Define Context Menu.
webview.setContextMenuEnabled(false);
webview.setOnContextMenuRequested(contextMenuRequestHandler);
webview.addEventHandler(KeyEvent.KEY_PRESSED, keyEventHandler);
// Define Events.
engine.setOnError(onErrorHandler);
engine.getLoadWorker().stateProperty().addListener(stateChangeListener);
engine.setConfirmHandler(confirmHandler);
engine.setCreatePopupHandler(createPopupHandler);
// Load HTML
engine.load(new File(TYNYMCE_LOCATION).toURI().toURL().toExternalForm());
} catch (MalformedURLException e) {
LOGGER.error(ValueUtil.toString(e));
}
// Read Property Chagne Listener.
readOnlyProperty.addListener(readOnyChangeListener);
return this;
}
示例10: initialize
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
public void initialize() {
webView.setZoom(1.0);
WebEngine webEngine = webView.getEngine();
iotworkshopView.setOnShowing(e -> {
AppBar appBar = getApp().getAppBar();
// Use Back button, not the Menu button, to prevent showing the drawer
// This prevents also from adding this view to the stack, so there is no
// need for adding a Skip policy
appBar.setNavIcon(getApp().getNavBackButton());
appBar.setTitleText(OTNView.IOT_WORKSHOP.getTitle());
});
ProgressBar indicator = new ProgressBar();
indicator.progressProperty().bind(webView.getEngine().getLoadWorker().progressProperty());
iotworkshopView.setTop(indicator);
listener = (obs, ov, nv) -> {
switch(nv) {
case SUCCEEDED:
case CANCELLED:
case FAILED:
indicator.progressProperty().unbind();
iotworkshopView.setTop(null);
webView.getEngine().getLoadWorker().stateProperty().removeListener(listener);
break;
}
};
webView.getEngine().getLoadWorker().stateProperty().addListener(listener);
webEngine.load("https://apex.oracle.com/pls/apex/f?p=IOTWS:SIGNUP");
}
示例11: check
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
public final boolean check(WebEngine e, String u) {
if (!EOption.blockMalware.b) return true;
try {
URL url = new URL(u);
if (ZunoAPI.block == null || ZunoAPI.block.isEmpty() || ZunoAPI.block.size() < 1) return true;
if (ZunoAPI.block.contains(url.toURI().getHost())) {
e.getLoadWorker().cancel();
e.load("https://zunozap.github.io/pages/blocked.html?" + url.toURI().getHost());
return false;
}
} catch (IOException | URISyntaxException e1) {}
return true;
}
示例12: start
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception
{
StackPane container = new StackPane();
Scene scene = new Scene(container, SIZE, SIZE);
styleInfo = getParameters().getRaw().get(0);
WebView view = new WebView();
WebEngine web = view.getEngine();
web.load(CSSLauncher.class.getResource("resources/textSample.html").toExternalForm());
GridPane viewPane = new GridPane();
viewPane.setMaxSize(SIZE, SIZE);
viewPane.getChildren().add(view);
container.getChildren().addAll(viewPane);
stage.setTitle("Launcher");
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
示例13: start
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
public void start(Stage stage) {
StackPane container = new StackPane();
scene = new Scene(container, 800, 800);
view = new WebView ();
WebEngine engine = view.getEngine();
//using CSSLauncher's test.html
engine.load(CSSLauncher.class.getResource("resources/test.html").toExternalForm());
setHandlers();
GridPane viewPane = new GridPane();
viewPane.setMaxSize(size, size);
viewPane.getChildren().add(view);
container.getChildren().addAll(viewPane, zoomingButton);
stage.setTitle("Launcher");
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
示例14: loadPage
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
public void loadPage(TextField textField, //ProgressBar progressBar,
WebEngine webEngine, WebView webView) {
String route = textField.getText();
if (route !=null)
if (!route.substring(0, 7).equals("http://")) {
route = "http://" + route;
textField.setText(route);
}
System.out.println("Loading route: " + route);
//progressBar.progressProperty().bind(webEngine.getLoadWorker().progressProperty());
webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
@Override
public void changed(ObservableValue<? extends State> value,
State oldState, State newState) {
if(newState == State.SUCCEEDED){
System.out.println("Location loaded + " + webEngine.getLocation());
}
}
});
webEngine.load(route);
}
示例15: showOnlineGame
import javafx.scene.web.WebEngine; //導入方法依賴的package包/類
public void showOnlineGame(GameOnline game) {
WebEngine webEngine = webView.getEngine();
webEngine.setJavaScriptEnabled(true);
URI uri = URI.create(MainApp.webConnector.getUrlFromGame(game));
List<String> cookies = new ArrayList<>();
for(Cookie cookie : MainApp.webConnector.cookies.getCookies()) {
cookies.add(cookie.getName() + "=" + cookie.getValue());
}
Map<String, List<String>> headers = new LinkedHashMap<String, List<String>>();
headers.put("Set-Cookie", cookies);
try {
CookieHandler.getDefault().put(uri, headers);
} catch (IOException e) {
e.printStackTrace();
}
webEngine.load(uri.toString());
}