Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove The ScrollBar in the WebView Javafx [closed]

How to remove the scrollbar automatically in the WebView of Javafx ?

When you click "Cadastre" will open a screen, this screen is in javascript and is unconfigured because of the scrollbar, so we wanted to remove it.

enter image description here

like image 274
Folie Avatar asked Mar 19 '13 11:03

Folie


1 Answers

Normally for a ScrollPane you would do something like this:

scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollBarPolicy.NEVER);

However, the scrollbars inside WebView are not your JavaFX UI control, but a part of the displayed webpage. Thus, you control them with CSS:

body {
    overflow-x: hidden;
    overflow-y: hidden;
}

You can save this as a .css and apply it as a user stylesheet, similarly user style sheets in normal browsers, using this code:

webView.getEngine().setUserStyleSheetLocation("path/to/style.css");

If the user stylesheet you created is a part of your project's resources then you should externalize it so:

webView.getEngine().setUserStyleSheetLocation(getClass().getResource("/path/to/style.css").toExternalForm());
like image 53
Dreen Avatar answered Nov 01 '22 13:11

Dreen