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


Java WebView类代码示例

本文整理汇总了Java中javafx.scene.web.WebView的典型用法代码示例。如果您正苦于以下问题:Java WebView类的具体用法?Java WebView怎么用?Java WebView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WebView类属于javafx.scene.web包,在下文中一共展示了WebView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javafx.scene.web.WebView; //导入依赖的package包/类
@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();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:40,代码来源:HTMLEditorSample.java

示例2: IWURLField

import javafx.scene.web.WebView; //导入依赖的package包/类
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>");
                }
            }
        }
    });
}
 
开发者ID:nick-ivanov,项目名称:icewolf,代码行数:25,代码来源:IWURLField.java

示例3: openHelpText

import javafx.scene.web.WebView; //导入依赖的package包/类
/**
 * @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();
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:20,代码来源:ViewUtils.java

示例4: initializeContext

import javafx.scene.web.WebView; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FreeGeoProviderTest.java

示例5: 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

示例6: WebViewSample

import javafx.scene.web.WebView; //导入依赖的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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:37,代码来源:WebViewSample.java

示例7: initComponent

import javafx.scene.web.WebView; //导入依赖的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;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:29,代码来源:ACEEditor.java

示例8: start

import javafx.scene.web.WebView; //导入依赖的package包/类
@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();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:37,代码来源:HyperlinkWebViewSample.java

示例9: showOverview

import javafx.scene.web.WebView; //导入依赖的package包/类
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();
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:20,代码来源:EvaluatorHandler.java

示例10: setTabs

import javafx.scene.web.WebView; //导入依赖的package包/类
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);
}
 
开发者ID:JMurf,项目名称:NetCompile,代码行数:21,代码来源:TestSceneController.java

示例11: saveCompile

import javafx.scene.web.WebView; //导入依赖的package包/类
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");
}
 
开发者ID:JMurf,项目名称:NetCompile,代码行数:20,代码来源:TestSceneController.java

示例12: start

import javafx.scene.web.WebView; //导入依赖的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();
}
 
开发者ID:jfree,项目名称:jfree-fxdemos,代码行数:35,代码来源:OrsonChartsFXDemo.java

示例13: createChartPane

import javafx.scene.web.WebView; //导入依赖的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;
}
 
开发者ID:jfree,项目名称:jfree-fxdemos,代码行数:26,代码来源:OrsonChartsFXDemo.java

示例14: UARTPanel

import javafx.scene.web.WebView; //导入依赖的package包/类
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);
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:23,代码来源:UARTPanel.java

示例15: ConsolePane

import javafx.scene.web.WebView; //导入依赖的package包/类
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);
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:20,代码来源:ConsolePane.java


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