Java 类javafx.scene.web.WebView 实例源码

项目:marathonv5    文件:HTMLEditorSample.java   
@Override
public void start(Stage stage) {
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(650);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();     
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final HTMLEditor htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(245);
    htmlEditor.setHtmlText(INITIAL_TEXT);

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();


    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setStyle("-fx-background-color: white");
    scrollPane.setContent(browser);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Load Content in Browser");
    root.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction((ActionEvent arg0) -> {
        webEngine.loadContent(htmlEditor.getHtmlText());
    });

    root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}
项目:icewolf    文件:IWURLField.java   
public IWURLField(WebView webView, boolean secured, Tab tab) {
    this.webView = webView;
    this.tab = tab;
    this.securedHTTP = secured;
    setText(IWPropertyHelper.getProperty("default_homepage"));

    webView.getEngine().getLoadWorker().stateProperty().addListener(
    new ChangeListener<State>() {
        @Override
        public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
            if (newValue == State.SUCCEEDED) {
                tab.setText(webView.getEngine().getTitle());
            }

            if (newValue == State.FAILED) {
                if(getText().toString().equals("")) {
                    webView.getEngine().loadContent("<html><title>Empty Tab</title><body></body></html>");
                } else {
                    webView.getEngine().loadContent("<html><title>Oops!</title><body><b>Page not found!</b></body></html>");
                }
            }
        }
    });
}
项目:stvs    文件:ViewUtils.java   
/**
 * @param url the url of the website to be shown
 */
public static void openHelpText(String title, String url) {
    WebView wv = new WebView();
    wv.getEngine().setJavaScriptEnabled(false);
    wv.getEngine().load(url);
    Scene pane = new Scene(wv);
    Stage state = new Stage();
    state.setScene(pane);
    //                pane.getButtonTypes().add(ButtonType.CLOSE);
    state.setAlwaysOnTop(true);
    state.setTitle(title);
    state.setResizable(true);
    state.setOpacity(0.8);
    state.setMinHeight(250);
    state.setMinWidth(250);
    state.show();
}
项目:incubator-netbeans    文件:FreeGeoProviderTest.java   
@BeforeClass
public static void initializeContext() throws Exception {
    final JFXPanel p = new JFXPanel();
    final URL u = DialogsTest.class.getResource("/org/netbeans/api/htmlui/empty.html");
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            WebView v = new WebView();
            Scene s = new Scene(v);
            p.setScene(s);
            NbBrowsers.load(v, u, new Runnable() {
                @Override
                public void run() {
                    ctx = BrwsrCtx.findDefault(DialogsTest.class);
                    down.countDown();
                }
            }, null);
        }
    });
    down.await();
    JFrame f = new JFrame();
    f.getContentPane().add(p);
    f.pack();
    f.setVisible(true);
}
项目:incubator-netbeans    文件:DialogsTest.java   
@BeforeClass
public static void initializeContext() throws Exception {
    final JFXPanel p = new JFXPanel();
    final URL u = DialogsTest.class.getResource("/org/netbeans/api/htmlui/empty.html");
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            WebView v = new WebView();
            Scene s = new Scene(v);
            p.setScene(s);
            NbBrowsers.load(v, u, new Runnable() {
                @Override
                public void run() {
                    ctx = BrwsrCtx.findDefault(DialogsTest.class);
                    down.countDown();
                }
            }, null);
        }
    });
    down.await();
    JFrame f = new JFrame();
    f.getContentPane().add(p);
    f.pack();
    f.setVisible(true);
}
项目:marathonv5    文件:HyperlinkWebViewSample.java   
@Override
public void start(Stage stage) {
    VBox vbox = new VBox();
    Scene scene = new Scene(vbox);
    stage.setTitle("Hyperlink Sample");
    stage.setWidth(570);
    stage.setHeight(550);

    selectedImage.setLayoutX(100);
    selectedImage.setLayoutY(10);

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    for (int i = 0; i < captions.length; i++) {
        final Hyperlink hpl = hpls[i] = new Hyperlink(captions[i]);
        final Image image = images[i] =
            new Image(getClass().getResourceAsStream(imageFiles[i]));
        hpl.setGraphic(new ImageView (image));
        hpl.setFont(Font.font("Arial", 14));
        final String url = urls[i];

        hpl.setOnAction((ActionEvent e) -> {
            webEngine.load(url);
        });
    }

    HBox hbox = new HBox();
    hbox.setAlignment(Pos.BASELINE_CENTER);
    hbox.getChildren().addAll(hpls);
    vbox.getChildren().addAll(hbox, browser);
    VBox.setVgrow(browser, Priority.ALWAYS);

    stage.setScene(scene);
    stage.show();
}
项目:ReqMan    文件:EvaluatorHandler.java   
public void showOverview() {
    if (!manager.isCatalogueLoaded() || (manager.groupList() == null || manager.groupList().isEmpty())) {
        return;
    }
    SimpleOverviewBuilder overview = new SimpleOverviewBuilder(manager.getCatalogue(), manager.groupList());
    String export = overview.exportOverviewHTML();
    WebView view = new WebView();
    WebEngine engine = view.getEngine();
    engine.loadContent(export);
    HBox box = new HBox();
    view.prefWidthProperty().bind(box.widthProperty());
    view.prefHeightProperty().bind(box.heightProperty());
    Scene webScene = new Scene(box, evaluator.getWidth(), evaluator.getHeight());
    box.prefWidthProperty().bind(webScene.widthProperty());
    box.prefHeightProperty().bind(webScene.heightProperty());
    box.getChildren().add(view);
    PopupStage popupStage = new PopupStage("Overview", webScene);
    popupStage.showAndWait();
}
项目:NetCompile    文件:TestSceneController.java   
public void setTabs(String []fileNames, String dir) throws IOException{
   //get file contents to set web view
    //test.setText(jsonArray[jsonArray.length-1].replace("\"", "")); 

    //set test type by getting last element in array    
     for (int i =0 ; i <fileNames.length; i++) {
        Tab tab = new Tab();
        String s = fileNames[i].substring(1,fileNames[i].indexOf(".")) ;
        tab.setText(s);
        WebView w = new WebView();
        String file = dir + "/" + s + ".html";
        w.getEngine().load( file );
        problem_tabs.getTabs().add(tab);
        problem_tabs.getTabs().get(i).setContent(w);
    }       
    problem_tabs.setVisible(true);
    //test.setVisible(true);
    //date.setVisible(true);
    //time.setVisible(true);
}
项目:NetCompile    文件:TestSceneController.java   
public void saveCompile() throws Exception {       
    WebView w =(WebView) problem_tabs.getSelectionModel().getSelectedItem().getContent(); 
    String code = (String)w.getEngine().executeScript("editor.getValue()");
    System.out.println(code);
    code_output.setText("SUBMITTING...\n-------------------------------------\n");
    String[] ret = FileHelper.uploadEditorContent(this);
    for( int i=0; i<ret.length; i++ ) {
        if( ret[i].length() == 0 ) continue;
        if( ret[i].charAt(0) == '\"' ) {
            ret[i] = ret[i].substring(1);
        }
        if( ret[i].charAt(ret[i].length()-1) == '\"' ) {
            ret[i] = ret[i].substring(0, ret[i].length()-1);
        }
        //    ret[i] = ret[i].substring(1, ret[i].length()-1);
        code_output.setText(code_output.getText() + ret[i] + "\n");
    }
    //code_output.setText(code_output.getText() + "-------------------------------------\n");
}
项目:jfree-fxdemos    文件:OrsonChartsFXDemo.java   
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;
}
项目:WebPLP    文件:UARTPanel.java   
public UARTPanel()
{
    WebView view = new WebView();
    view.setContextMenuEnabled(false);
    webEngine = view.getEngine();

    messageQueue = new LinkedList<>();

    valueDisplayOptions = new LinkedHashMap<>();
    populateDisplayOptions();

    ObservableValue<State> property = webEngine.getLoadWorker().stateProperty();
    OnLoadListener.register(this::onLoad, property);

    String content = "<html><head></head><body " + styleString() + "></body></html>";
    webEngine.loadContent(content);

    HBox controlPane = createControlPane();

    this.setCenter(view);
    this.setBottom(controlPane);
}
项目:WebPLP    文件:ConsolePane.java   
public ConsolePane()
{
    WebView view = new WebView();
    view.setContextMenuEnabled(false);
    webEngine = view.getEngine();

    messageQueue = new LinkedList<>();

    ObservableValue<State> property = webEngine.getLoadWorker().stateProperty();
    OnLoadListener.register(this::onLoad, property);

    String content = "<html><head></head><body></body></html>";
    webEngine.loadContent(content);

    ConsolePaneEventHandler eventHandler = new ConsolePaneEventHandler();
    EventRegistry.getGlobalRegistry().register(eventHandler);

    this.setCenter(view);
}
项目:file-transfer    文件:HtmlPage.java   
public HtmlPage(String link) {
    VBox root = new VBox();
    Scene scene = new Scene(root);
    setTitle("FileSend - Page");
    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
    try {
        httpsLoad(webEngine, link);
    } catch (NoSuchAlgorithmException | KeyManagementException e) {
        e.printStackTrace();
    }
    root.getChildren().add(browser);
    VBox.setVgrow(browser, Priority.ALWAYS);
    getIcons().add(new Image(getClass().getResourceAsStream(".." + File.separator + "images" + File.separator + "logo.png")));
    setScene(scene);
    setMaximized(true);
}
项目:GestureFX    文件:ArbitraryNodeSample.java   
@Override
public Node mkRoot() {
    try {
        Parent node  = FXMLLoader.load(getClass().getResource("/ComplexScene.fxml"));
        node.setPickOnBounds(true);
        node.setMouseTransparent(true);
        WebView webview = (WebView) node.lookup("webview");
        if(webview != null){
            webview.getEngine().load("http://purecss3.net/doraemon/doraemon_css3.html");
        }

        GesturePane pane = new GesturePane(new SubScene(node, 500, 500));
        VBox.setVgrow(pane, Priority.ALWAYS);
        Label description = new Label("Zoom and scroll on the SubScene below, " +
                                              "observe that controls in JavaFX are vectors " +
                                              "and that lighting effects are respected" +
                                              "(different zoom alters light distance).");
        description.setWrapText(true);
        description.setPadding(new Insets(16));
        return new VBox(description, pane);

    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:Netkit    文件:WebViewUtils.java   
public static void wait(WebView view) {
    Stage stage = new Stage();

    WebEngine engine = view.getEngine();
    engine.documentProperty().addListener((observable, o, n) -> stage.close());

    Scene scene = new Scene(view);
    stage.initStyle(StageStyle.UNDECORATED);
    stage.setWidth(1);
    stage.setHeight(1);
    stage.setScene(scene);

    stage.showAndWait();
    stage.close();
}
项目:java.IF17wi    文件:HilfeDialog.java   
public HilfeDialog() {
    super();
    initModality(Modality.APPLICATION_MODAL);

    browser = new WebView();
    webEngine = browser.getEngine();
    webEngine.load("https://de.wikipedia.org/wiki/Vier_gewinnt");
    ok = new Button("OK");
    ok.addEventHandler(ActionEvent.ACTION, e -> this.close());

    buttonBox = new HBox(20);
    buttonBox.setAlignment(Pos.CENTER_RIGHT);
    buttonBox.getChildren().add(ok);

    vBox = new VBox(20, browser, buttonBox);
    VBox.setVgrow(browser, Priority.ALWAYS);

    Scene scene = new Scene(vBox);
    this.setScene(scene);
}
项目:javafx-dataviewer    文件:DataViewer.java   
private void createView() {
    webView = new WebView();
       webView.setContextMenuEnabled(false);
    webEngine = webView.getEngine();
    webEngine.documentProperty().addListener(new ChangeListener<Document>() {
        @Override
        public void changed(ObservableValue<? extends Document> prop, Document oldDoc, Document newDoc) {
            logger.debug("WebView loaded dataviewer with id : [{}]", udID);
            if (enableFireBug)
                enableFirebug(webEngine);
        }
    });
    String urlToLoad = getUrlToLoad() + udID;
    logger.debug("Loading: [{}]", urlToLoad);
    webEngine.load(urlToLoad);

    setStyle("-fx-background-color: white;");
    setCenter(webView);
    setTop(topMenu = new TopMenu(plotData, latestConfig, this));
}
项目:Gargoyle    文件:SimpleTextView.java   
@FXML
public void miOpenHtmlWevViewOnAction() {
    String content = codeArea.getText();

    try {
        WebView webView = new WebView();
        webView.getEngine().loadContent(content);

        FxUtil.createStageAndShow(webView, stage -> {
            stage.setAlwaysOnTop(true);
            stage.initOwner(getScene().getWindow());
            stage.focusedProperty().addListener((oba, o, n) -> {
                if (!n)
                    stage.close();

            });
        });

    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Gargoyle    文件:SqlPane.java   
/**
 * Export HTML <br/>
 * 
 * TODO 템플릿 파일과 데이터를 결합하여 HTML을 보여주는 기능 구현 <br/>
 * 
 * @작성자 : KYJ
 * @작성일 : 2017. 12. 4.
 * @param e
 */
public void menuExportHtmlOnAction(ActionEvent e) {
    // TODO

    ObservableList<Map<String, Object>> items = this.tbResult.getItems();

    String template = ConfigResourceLoader.getInstance().get("default.database.view.template");

    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("data", items);

    String velocityToText = ValueUtil.getVelocityToText(template, map, false);

    System.out.println(velocityToText);

    WebView v = new WebView();
    v.getEngine().loadContent(velocityToText);
    FxUtil.createStageAndShow(v, stage->{
        stage.setWidth(1200d);
        stage.setHeight(800d);
    });

}
项目:Gargoyle    文件:XmlDiffAppController.java   
private void showWebView(ChunkWrapper selectedItem) {
    String str = selectedItem.getStr().trim();
    if (str.startsWith("tagvalue")) {
        str = str.replaceAll("^tagvalue=\"", "");
        String html = str.substring(0, str.length() - 2);
        WebView webView = new WebView();

        html = html.replaceAll("&lt;", "<");
        html = html.replaceAll("&gt;", ">");
        String format = String.format("<!DOCTYPE html><html><body>%s</body></html>", html);

        FxUtil.createStageAndShow("html", webView, stage -> {
            stage.initOwner(SharedMemory.getPrimaryStage());
        });
        webView.getEngine().loadContent(format, "text/html");
    }
}
项目:gralog    文件:AboutStage.java   
public AboutStage(Application host) {
    okButton = new Button("OK");
    okButton.setOnAction(e -> this.close());

    webView = new WebView();
    webEngine = webView.getEngine();
    webEngine.loadContent(
        "<b>Gralog</b><br/>"
        + "Graphs, Algorithms, Logic and Games<br/>"
        + "©2015-2016 Technische Universität Berlin<br/>"
        + "Lehrstuhl für Logik und Semantik"
    );

    root = new BorderPane();
    root.setCenter(webView);
    root.setBottom(okButton);
    scene = new Scene(root, 350, 200);

    this.setScene(scene);
    this.setTitle("About Gralog");
    this.initModality(Modality.APPLICATION_MODAL);
}
项目:notey    文件:NoteyController.java   
private static Button setUpNoteyButton(TextArea documentText, TextField documentTitle,
Button addDocumentButton, Button saveButton, Button saveAllButton, WebView webViewBox,
String text, String title){
    Button newButton = new Button("Document");
    newButton.setMinWidth(0);
    newButton.setPrefWidth(addDocumentButton.getPrefWidth());
    newButton.setMaxWidth(addDocumentButton.getMaxWidth());
    newButton.setOnAction(e -> {
        setSideButtonsOnClickHandler(documentText, documentTitle, saveButton, saveAllButton,
        e, title,text, webViewBox);
    });
    documentText.setText(text);
    documentTitle.setText(title);
    newButton.setText(title);
    return newButton;

}
项目:livro-javafx-pratico    文件:NavegaSites.java   
@Override
   public void start(Stage s) {
    // criando uma lista visual de Strings, um webView e uma caixinha pra colocar as coisas
ListView<String> listaSites = new ListView<>();
WebView webView = new WebView();
       HBox raiz = new HBox(20);

// Para cada site no array adicionamos na lista visual
Stream.of(sites).forEach(listaSites.getItems()::add);

// Quando o usuário seleciona um item, carregamos a página
listaSites.getSelectionModel().selectedItemProperty().addListener(
    (obs, o, n) -> {
        if(n != null) webView.getEngine().load("http://www." + n);
});

// a lista não permite seleção de página quando uma página está sendo carregada
listaSites.disableProperty().bind(webView.getEngine().getLoadWorker().runningProperty());

// formalidades...
raiz.getChildren().addAll(listaSites, webView);
       s.setScene(new Scene(raiz));
       s.show();
   }
项目:MineIDE-UI    文件:PopupCredits.java   
public static void init()
{
    Stage stage = new Stage();
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.initOwner(MineIDE.primaryStage);
    stage.getIcons().add(new Image(Utils.IMG_DIR + "icon.png"));
    stage.setTitle("Credits");

    StackPane creditsVbox = new StackPane();

    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    HtmlReader htmlReader = new HtmlReader();
    htmlReader.initReading(Utils.HTML_DIR + "credits.html");
    webEngine.loadContent(htmlReader.getOutputContent());

    creditsVbox.getChildren().add(browser);

    Scene scene = new Scene(creditsVbox, Gui.width / 1.5, Gui.height / 1.5);
    scene.setFill(Color.OLDLACE);

    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();
}
项目:openjfx-8u-dev-tests    文件:FXCanvasBrowserApp.java   
protected FXCanvasBrowserApp() {
    shell = new Shell();
    shell.setText(this.getClass().getSimpleName());
    shell.setLayout(new FillLayout());
    FXCanvas fxCanvas = new FXCanvas(shell, SWT.BORDER);

    browser = new WebView();
    browser.getEngine().getLoadWorker().stateProperty().addListener(
            new ChangeListener<State>() {
        public void changed(ObservableValue ov, State oldState, State newState) {
            if (newState == State.SUCCEEDED) {
                successLabel.setText(SUCCESS_MESSAGE);
            }
        }
    });
    fxCanvas.setScene(createScene());

    shell.pack();
    Monitor monitor = shell.getMonitor();
    Rectangle monitorRect = monitor.getClientArea();
    Rectangle shellRect = shell.getBounds();
    shellRect.x = Math.max(0, (monitorRect.width - shellRect.width) / 2);
    shellRect.y = Math.max(0, (monitorRect.height - shellRect.height) / 2);
    shell.setBounds(shellRect);
    shell.open();
}
项目:openjfx-8u-dev-tests    文件:MinHeightTestApp.java   
public void start(Stage stage){
    WebView view = new WebView();
    WebEngine e = view.getEngine();
    e.loadContent("<div style='height: 50px; background-color: limegreen;'>Narrow div</div>");
    view.setMinHeight(MIN_HEIGHT);
    view.setId(VIEW_ID);

    VBox box = new VBox();
    box.setMaxHeight(MIN_HEIGHT - 10);
    box.setMinHeight(MIN_HEIGHT - 10);
    box.setPrefHeight(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(view.getHeight());
}
项目:openjfx-8u-dev-tests    文件:PrefHeightTestApp.java   
public void start(Stage stage){
    WebView view = new WebView();
    view.setPrefHeight(PREF_HEIGHT);
    view.setId(VIEW_ID);

    VBox box = new VBox();
    box.getChildren().add(view);

    final Scene scene = new Scene(box);
    stage.setTitle(VIEW_ID);
    stage.setScene(scene);
    stage.sizeToScene();
    stage.show();

    System.out.println(view.getHeight());
}
项目:openjfx-8u-dev-tests    文件:MinWidthTestApp.java   
public void start(Stage stage){
    WebView view = new WebView();
    WebEngine e = view.getEngine();
    e.loadContent("<div style='width: 50px; background-color: limegreen;'>Narrow div</div>");
    view.setMinWidth(MIN_WIDTH);
    view.setId(VIEW_ID);

    HBox box = new HBox();
    box.setMaxWidth(MIN_WIDTH - 10);
    box.setMinWidth(MIN_WIDTH - 10);
    box.setPrefWidth(MIN_WIDTH - 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(view.getWidth());
}
项目:openjfx-8u-dev-tests    文件:MaxSizeTestApp.java   
public void start(Stage stage){
    WebView view = new WebView();
    WebEngine e = view.getEngine();
    e.loadContent("<div style='height: 1024px; width: 1024; background-color: limegreen;'>Big div</div>");
    view.setMaxSize(MAX_WIDTH, MAX_HEIGHT);
    view.setId(VIEW_ID);

    HBox box = new HBox();
    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());
}
项目:openjfx-8u-dev-tests    文件:MinSizeTestApp.java   
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());
}
项目:openjfx-8u-dev-tests    文件:PrefSizeTestApp.java   
public void start(Stage stage){
    WebView view = new WebView();
    view.setPrefSize(PREF_WIDTH, PREF_HEIGHT);
    view.setId(VIEW_ID);

    FlowPane pane = new FlowPane();
    pane.getChildren().add(view);

    final Scene scene = new Scene(pane);
    stage.setTitle(VIEW_ID);
    stage.setScene(scene);
    stage.sizeToScene();
    stage.show();

    System.out.println("Width:" + view.getWidth());
    System.out.println("Height:" + view.getHeight());
}
项目:openjfx-8u-dev-tests    文件:MaxHeightTestApp.java   
public void start(Stage stage){
    WebView view = new WebView();
    WebEngine e = view.getEngine();
    e.loadContent("<div style='height: 1024px; background-color: limegreen;'>Tall div</div>");
    view.setMaxHeight(MAX_HEIGHT);
    view.setId(VIEW_ID);

    HBox box = new HBox();
    box.getChildren().add(view);

    final Scene scene = new Scene(box);
    stage.setTitle(VIEW_ID);
    stage.setScene(scene);
    stage.sizeToScene();
    stage.show();

    System.out.println(view.getHeight());
}
项目:openjfx-8u-dev-tests    文件:PrefWidthTestApp.java   
public void start(Stage stage){
    WebView view = new WebView();
    view.setPrefWidth(PREF_WIDTH);
    view.setId(VIEW_ID);

    HBox box = new HBox();
    box.getChildren().add(view);

    final Scene scene = new Scene(box);
    stage.setTitle(VIEW_ID);
    stage.setScene(scene);
    stage.sizeToScene();
    stage.show();

    System.out.println(view.getWidth());
}
项目:openjfx-8u-dev-tests    文件:prefSizeTest.java   
/**
 * Test case for javafx.scene.web.WebView.setPrefSize method (sanity check).
 */
@Test(timeout=10000)
public void test1(){
    Platform.runLater(new Runnable() {
        public void run() {
            view = new WebView();
            view.setPrefSize(PREF_WIDTH, PREF_HEIGHT);
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (view != null) && (view.getPrefWidth() == PREF_WIDTH)
                    && (view.getPrefHeight() == PREF_HEIGHT);
        }
    });
}
项目:openjfx-8u-dev-tests    文件:maxSizeTest.java   
/**
 * Test case for javafx.scene.web.WebView.setMaxSize method (sanity check).
 */
@Test(timeout=10000)
public void test1() {
    Platform.runLater(new Runnable() {
        public void run() {
            view = new WebView();
            view.setMaxSize(MAX_WIDTH, MAX_HEIGHT);
         }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (view != null) && (view.getMaxWidth() == MAX_WIDTH)
                    && (view.getMaxHeight() == MAX_HEIGHT);
        }
    });
}
项目:openjfx-8u-dev-tests    文件:minSizeTest.java   
/**
 * Test case for javafx.scene.web.WebView.setMinSize method (sanity check).
 */
@Test(timeout=10000)
public void test1(){
    Platform.runLater(new Runnable() {
        public void run() {
            view = new WebView();
            view.setMinSize(MIN_WIDTH, MIN_HEIGHT);
        }
    });
    doWait(new Tester() {
        public boolean isPassed() {
            return (view != null) && (view.getMinWidth() == MIN_WIDTH)
                    && (view.getMinHeight() == MIN_HEIGHT);
        }
    });
}
项目:openjfx-8u-dev-tests    文件:FontLauncher.java   
@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();
}
项目:downloadclient    文件:WebViewWindow.java   
public WebViewWindow(WebView wv, String title) {
    super();
    this.webView = wv;
    this.webView.getEngine().setCreatePopupHandler(param -> {
        Object o = webView
                .getEngine()
                .executeScript(
                     "var list = document.querySelectorAll( ':hover' );"
                     + "for (i=list.length-1; i>-1; i--) "
                     + "{ if ( list.item(i).getAttribute('href') ) "
                     + "{ list.item(i).getAttribute('href'); break; } }");
        if (o != null) {
            Misc.startExternalBrowser(o.toString());
        }
        return null;
    });
    super.setTitle(title);
}
项目:openjfx-8u-dev-tests    文件:RichTextLauncher.java   
private Scene createScene(String url) {
    view = new WebView();
    htmlEditor =  new HTMLEditor();

    view.getEngine().load(url);

    final VBox box = new VBox();
    view.setMaxHeight(300);
    view.setMinHeight(300);
    htmlEditor.setMaxHeight(300);
    htmlEditor.setMinHeight(300);
    box.getChildren().addAll(view, htmlEditor);

    final Scene scene = new Scene(box);

    scene.setFill(Color.GRAY);
    return scene;
}
项目:openjfx-8u-dev-tests    文件:ReloadLauncher.java   
private Scene createScene(final String path, final String url) {
    view = new WebView();
    write(path, DOC1);
    view.getEngine().load(url);

    Button rewrite = new Button("Rewrite document");
    rewrite.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            write(path, DOC2);
        }
    });

    final VBox box = new VBox();
    box.getChildren().addAll(rewrite, view);

    final Scene scene = new Scene(box);

    scene.setFill(Color.GRAY);
    return scene;
}