Java Code Examples for javafx.scene.web.WebView#setContextMenuEnabled()

The following examples show how to use javafx.scene.web.WebView#setContextMenuEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebFrame.java    From oim-fx with MIT License 5 votes vote down vote up
private void init() {
    
    VBox rootVBox = new VBox();
    
    this.setCenter(rootVBox);
   // this.setBackground("Resources/Images/Wallpaper/1.jpg");
    this.setTitle("登录");
    this.setWidth(380);
    this.setHeight(600);
    this.setRadius(10);
    
    StackPane u = new StackPane();
    u.setPrefSize(50, 100);
   // String hString = this.getClass().getResource("/resources/chat/index.html").toString();
    File file = new File("Resources/Images/Head/User/90_100.gif");
    
    String fullPath = file.getAbsolutePath();
    String htmlText = "<html><body> <lable>666</label>"
            + "<img src=\"file:/"+fullPath+"\" />"
            + "</body></html> ";
    System.out.println(htmlText);
    WebView webView = new WebView();
    webView.setContextMenuEnabled(false);
    WebEngine we = webView.getEngine();
    //we.load(hString);
    Image logoIamge = new Image(this.getClass().getResource("/resources/login/logo.png").toExternalForm(), true);
    ImageView logoImageView = new ImageView();
    logoImageView.setImage(logoIamge);
    we.loadContent(htmlText);
   // Document d = we.getDocument();
    // Element root = we.getDocument().getDocumentElement();
    // NodeList nl = root.getElementsByTagName("body");
    // Node node = nl.item(0);

    //node.appendChild(node);
    rootVBox.getChildren().add(u);
    rootVBox.getChildren().add(webView);
}
 
Example 2
Source File: SamplePage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected WebView getWebView() {
    if (engine == null) {
        webView = new WebView();
        webView.setContextMenuEnabled(false);
        engine = webView.getEngine();
    }
    return webView;
}
 
Example 3
Source File: SamplePage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected WebView getWebView() {
    if (engine == null) {
        webView = new WebView();
        webView.setContextMenuEnabled(false);
        engine = webView.getEngine();
    }
    return webView;
}
 
Example 4
Source File: SamplePage.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
protected WebView getWebView() {
	if (engine == null) {
		webView = new WebView();
		webView.setContextMenuEnabled(false);
		engine = webView.getEngine();
	}
	return webView;
}
 
Example 5
Source File: FxWebViewExample2.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage stage)
{
	// Create the WebView
	WebView webView = new WebView();

	// Disable the context menu
	webView.setContextMenuEnabled(false);

	// Increase the text font size by 20%
	webView.setFontScale(1.20);

	// Set the Zoom 20%
	webView.setZoom(1.20);

	// Set font smoothing type to GRAY
	webView.setFontSmoothingType(FontSmoothingType.GRAY);

	// Create the WebEngine
	final WebEngine webEngine = webView.getEngine();
	// Load the StartPage
	webEngine.load("http://www.google.com");

	// Update the stage title when a new web page title is available
	webEngine.titleProperty().addListener(new ChangeListener<String>()
	{
	    public void changed(ObservableValue<? extends String> ov,
	            final String oldvalue, final String newvalue)
	    {
	    	stage.setTitle(newvalue);
	    }
	});

	// Create the VBox
	VBox root = new VBox();
	// Add the Children to the VBox
	root.getChildren().add(webView);

	// Set the Style-properties of the VBox
	root.setStyle("-fx-padding: 10;" +
			"-fx-border-style: solid inside;" +
			"-fx-border-width: 2;" +
			"-fx-border-insets: 5;" +
			"-fx-border-radius: 5;" +
			"-fx-border-color: blue;");

	// Create the Scene
	Scene scene = new Scene(root);
	// Add  the Scene to the Stage
	stage.setScene(scene);
	// Display the Stage
	stage.show();
}