ObservableList<String> names = FXCollections.observableArrayList("1","2","3","4","5","6","7"); final ListView<String> listView = new ListView<String>(names); stage.setOnShown(new EventHandler<WindowEvent>(){ boolean hasRun = false; @Override public void handle(WindowEvent arg0) { if(!hasRun){ for (Node node: listView.lookupAll(".scroll-bar")) { if (node instanceof ScrollBar) { final ScrollBar bar = (ScrollBar) node; bar.valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> value, Number oldValue, Number newValue) { System.out.println(bar.getOrientation() + " " + newValue); } }); } } hasRun = true; } }});
@Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { for (Node child : getChildren()) { if (child.getStyleClass().get(0).equals("increment-button") || child.getStyleClass().get(0).equals( "decrement-button")) { if (getSkinnable().getOrientation() == Orientation.VERTICAL) { child.setStyle("-fx-padding: 0.0em " + ((endWidth - startWidth) * newValue.doubleValue() + startWidth) + "pt 0.0em 0.0em;}"); } else if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { child.setStyle("-fx-padding: " + ((endWidth - startWidth) * newValue.doubleValue() + startWidth) + "pt 0.0em 0.0em 0.0em;}"); } } } } });
growScrollbarTransition.stop(); if (getSkinnable().getOrientation() == Orientation.VERTICAL) { getSkinnable().setStyle(" -fx-padding: -1.0 0.0 -1.0 0.0;"); } else { if (getSkinnable().getOrientation() == Orientation.VERTICAL) { child.setStyle("-fx-background-color: linear-gradient(rgb(238.0, 238.0, 238.0, 0.8) 0.0%, rgb(255.0, 255.0, 255.0, 0.8) 100.0%);" + "-fx-border-width: 0.0 0.0 0.0 1.0;" + "-fx-border-insets: 0.0 0.0 0.0 -1.0;" + "-fx-border-color: rgb(198.0, 198.0, 198.0);"); } else if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { child.setStyle("-fx-background-color: linear-gradient(rgb(238.0, 238.0, 238.0, 0.8) 0.0%, rgb(255.0, 255.0, 255.0, 0.8) 100.0%);" + "-fx-border-width: 1.0 0.0 0.0 0.0;" + "-fx-border-insets: -1.0 0.0 0.0 0.0;" + "-fx-border-color: rgb(198.0, 198.0, 198.0);"); if (getSkinnable().getOrientation() == Orientation.VERTICAL) { child.setStyle("-fx-background-radius: 6.0;" + "-fx-background-insets: 0.0 2.0 0.0 2.0;"); } else if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { child.setStyle("-fx-background-radius: 6.0;" + "-fx-background-insets: 2.0 0.0 2.0 0.0;"); if (getSkinnable().getOrientation() == Orientation.VERTICAL) { child.setStyle("-fx-padding: 0.0em 6.0pt 0.0em 0.0em"); } else if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { child.setStyle("-fx-padding: 6.0pt 0.0em 0.0em 0.0em");
if (node instanceof ScrollBar) { ScrollBar bar = (ScrollBar) node; if (bar.getOrientation().equals(Orientation.VERTICAL)) { scrollbar = bar;