Java Code Examples for javafx.scene.web.WebView#setMinSize()
The following examples show how to use
javafx.scene.web.WebView#setMinSize() .
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: WebViewBrowser.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example 2
Source File: WebViewBrowser.java From oim-fx with MIT License | 4 votes |
public WebViewPane() { VBox.setVgrow(this, Priority.ALWAYS); setMaxWidth(Double.MAX_VALUE); setMaxHeight(Double.MAX_VALUE); WebView webView = new WebView(); webView.setMinSize(500, 400); webView.setPrefSize(500, 400); final WebEngine webEngine = webView.getEngine(); webEngine.load("http://www.baidu.com"); final TextField locationField = new TextField("http://www.baidu.com"); Button goButton = new Button("Go"); EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { webEngine.load(locationField.getText().startsWith("http://") ? locationField.getText() : "http://" + locationField.getText()); } }; goButton.setDefaultButton(true); goButton.setOnAction(goAction); locationField.setMaxHeight(Double.MAX_VALUE); locationField.setOnAction(goAction); webEngine.locationProperty().addListener(e->{ System.out.println(webEngine.getLocation()); }); webEngine.locationProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { locationField.setText(newValue); } }); WebPage webPage = Accessor.getPageFor(webEngine); webPage.setEditable(true); 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(webView, 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, webView); getChildren().add(grid); }
Example 3
Source File: MapTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); mouseHandler = event -> { if (event.getClickCount() == 2) { centerLocation(); } }; locationListener = e -> redraw(); poiListener = c -> { while (c.next()) { if (c.wasPermutated()) { // Get items that have been permutated in list for (int i = c.getFrom(); i < c.getTo(); ++i) { updatePoi(tile.getPoiList().get(i)); } } else if (c.wasUpdated()) { // Get items that have been updated in list for (int i = c.getFrom(); i < c.getTo(); ++i) { updatePoi(tile.getPoiList().get(i)); } } else if (c.wasAdded()) { c.getAddedSubList().forEach(poi -> addPoi(poi)); } else if (c.wasRemoved()) { c.getRemoved().forEach(poi -> removePoi(poi)); } } }; titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getText()); text.setFill(tile.getTextColor()); Helper.enableNode(text, tile.isTextVisible()); webView = new WebView(); webView.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); webView.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); webView.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); webEngine = webView.getEngine(); webEngine.getLoadWorker().stateProperty().addListener((ov, o, n) -> { if (Worker.State.SUCCEEDED == n) { readyToGo = true; if (MapProvider.BW != tile.getMapProvider()) { changeMapProvider(tile.getMapProvider()); } updateLocation(); updateLocationColor(); tile.getPoiList().forEach(poi -> addPoi(poi)); addTrack(tile.getTrack()); updateTrackColor(); } }); URL maps = Tile.class.getResource("osm.html"); webEngine.load(maps.toExternalForm()); getPane().getChildren().addAll(titleText, webView, text); }
Example 4
Source File: MapTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); mouseHandler = event -> { if (event.getClickCount() == 2) { centerLocation(); } }; locationListener = e -> redraw(); poiListener = c -> { while (c.next()) { if (c.wasPermutated()) { // Get items that have been permutated in list for (int i = c.getFrom(); i < c.getTo(); ++i) { updatePoi(tile.getPoiList().get(i)); } } else if (c.wasUpdated()) { // Get items that have been updated in list for (int i = c.getFrom(); i < c.getTo(); ++i) { updatePoi(tile.getPoiList().get(i)); } } else if (c.wasAdded()) { c.getAddedSubList().forEach(poi -> addPoi(poi)); } else if (c.wasRemoved()) { c.getRemoved().forEach(poi -> removePoi(poi)); } } }; titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getText()); text.setFill(tile.getTextColor()); Helper.enableNode(text, tile.isTextVisible()); webView = new WebView(); webView.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); webView.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); webView.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); webEngine = webView.getEngine(); webEngine.getLoadWorker().stateProperty().addListener((ov, o, n) -> { if (Worker.State.SUCCEEDED == n) { readyToGo = true; if (MapProvider.BW != tile.getMapProvider()) { changeMapProvider(tile.getMapProvider()); } updateLocation(); updateLocationColor(); tile.getPoiList().forEach(poi -> addPoi(poi)); addTrack(tile.getTrack()); updateTrackColor(); } }); URL maps = Tile.class.getResource("osm.html"); webEngine.load(maps.toExternalForm()); getPane().getChildren().addAll(titleText, webView, text); }