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


Java WebView.setCache方法代码示例

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


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

示例1: Editor

import javafx.scene.web.WebView; //导入方法依赖的package包/类
public Editor() {
	WebView view = new WebView();
	view.setFontSmoothingType(FontSmoothingType.GRAY); // looks better than colored (LCD) blurring IMO

	// caching with SPEED hint is awful on Linux and or low power machines (see issue #24)
	// caching with QUALITY hint is indistinguishable from no caching as far as I can tell
	// to to remove potential problems it's probably not worth enabling caching at all
	view.setCache(false);

	pageLoaded = false;
	bridge = new Bridge(this);

	engine = view.getEngine();
	engine.setJavaScriptEnabled(true);

	// these error messages seem useless because they only warn about re-using web cache directories
	// which means that opening multiple instances of Simulizer gives error messages because both are trying to access
	// ~/.simulizer.GuiMode$App and ~/.simulizer.Simulizer
	//engine.setOnError((errorEvent) -> UIUtils.showErrorDialog("Editor JS Error", errorEvent.toString()));

	// making it so calling alert() from javascript outputs to the console
	engine.setOnAlert((event) -> System.out.println("javascript alert: " + event.getData()));

	mode = Mode.EDIT_MODE;

	// javascript does not have access to the outside clipboard
	view.setContextMenuEnabled(false);

	// handle copy and paste and other key-combinations manually
	getEventManager().addEventFilter(KeyEvent.KEY_PRESSED, this::handleKeyEvent);

	getContentPane().getChildren().add(view);
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:34,代码来源:Editor.java

示例2: createContent

import javafx.scene.web.WebView; //导入方法依赖的package包/类
public Parent createContent() {

        WebView webView = new WebView();
        webView.setCache(false);

        final WebEngine webEngine = webView.getEngine();
        webEngine.load(DEFAULT_URL);

        final TextField locationField = new TextField(DEFAULT_URL);
        webEngine.locationProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
            locationField.setText(newValue);
        });
        EventHandler<ActionEvent> goAction = (ActionEvent event) -> {
            webEngine.load(locationField.getText().startsWith("http://")
                    ? locationField.getText()
                    : "http://" + locationField.getText());
        };
        locationField.setOnAction(goAction);

        Button goButton = new Button("Go");
        goButton.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);
        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.setPrefSize(1400, 800);
        VBox.setVgrow(webView, Priority.ALWAYS);
        return vBox;
    }
 
开发者ID:bourgesl,项目名称:marlin-fx,代码行数:36,代码来源:WebViewTest.java


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