本文整理汇总了Java中javafx.scene.web.WebView.setMinSize方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setMinSize方法的具体用法?Java WebView.setMinSize怎么用?Java WebView.setMinSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.web.WebView
的用法示例。
在下文中一共展示了WebView.setMinSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WebViewPane
import javafx.scene.web.WebView; //导入方法依赖的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: start
import javafx.scene.web.WebView; //导入方法依赖的package包/类
public void start(Stage stage){
WebView view = new WebView();
WebEngine e = view.getEngine();
e.loadContent("<div style='height: 30px; width: 30; background-color: limegreen;'>Small div</div>");
view.setMinSize(MIN_WIDTH, MIN_HEIGHT);
view.setId(VIEW_ID);
VBox box = new VBox();
box.setMaxWidth(MIN_WIDTH - 10);
box.setPrefWidth(MIN_WIDTH - 10);
box.setMinWidth(MIN_WIDTH - 10);
box.setMaxHeight(MIN_HEIGHT - 10);
box.setPrefHeight(MIN_HEIGHT - 10);
box.setMinHeight(MIN_HEIGHT - 10);
box.getChildren().add(view);
final Scene scene = new Scene(box);
stage.setTitle(VIEW_ID);
stage.setScene(scene);
stage.sizeToScene();
stage.show();
System.out.println("Width:" + view.getWidth());
System.out.println("Height:" + view.getHeight());
}
示例3: initGraphics
import javafx.scene.web.WebView; //导入方法依赖的package包/类
@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);
}