updateTextAreaTask.messageProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> obs, String oldMessage, String newMessage) { taProgressText.setText(newMessage); ScrollBar scrollBar = (ScrollBar) taProgressText.lookup(".scroll-bar:vertical"); if (scrollBar != null) { scrollBar.setValue(scrollBar.getMax()); } } });
final ScrollBar scrollBar = new ScrollBar(); Button btn = new Button("Reset"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { scrollBar.setValue(scrollBar.getMin()); // Or if you have stored initial value somewhere use it scrollBar.setValue(myInitialValue); } });
private void scrollColumnIntoView(int colIndex, int jumpAhead) { double charWidth = this.content.getCharWidth(); double colOffset = charWidth * colIndex; double contentWidth = this.content.getWidth(); double curOffset = this.contentArea.horizontal.getValue(); if (colOffset < curOffset) { double jumpOffset = curOffset - jumpAhead * charWidth; if (colOffset < jumpOffset) { jumpOffset = colOffset; } double targetOffset = Math.max(this.contentArea.horizontal.getMin(), jumpOffset); this.contentArea.horizontal.setValue(targetOffset); } if (colOffset > curOffset + contentWidth) { double jumpOffset = curOffset + jumpAhead * charWidth; if (colOffset > jumpOffset + contentWidth) { jumpOffset = colOffset + contentWidth; } double targetOffset = Math.min(this.contentArea.horizontal.getMax(), jumpOffset); this.contentArea.horizontal.setValue(targetOffset); } }