当前位置: 首页>>代码示例>>Java>>正文


Java WebView.setMinSize方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:WebViewBrowser.java

示例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());
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:27,代码来源:MinSizeTestApp.java

示例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);
}
 
开发者ID:HanSolo,项目名称:tilesfx,代码行数:53,代码来源:MapTileSkin.java


注:本文中的javafx.scene.web.WebView.setMinSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。