Java fx: how to remove scrollbar from web view?

I want to remove the scrollbar from the web view since I am using web scrolling.

+3


source to share


1 answer


The WebView handles the scrolling automatically, so there is no need to put it in ScrollPane

, so you only need to make the controls the overflow CSS property or the Webkit-Specify property -webkit-scrollbar

(WebView based on Webkit engine)

If you download the page from the Internet and not from disk, you cannot manage the CSS yourself, you can enter the CSS style as the following piece of code.



final 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) {
            String scriptCode = "customize javascript to inject style";
            engine.executeScript(scriptCode);
        }
    }
});

      

+2


source







All Articles