ScrollBar bar = new ScrollBar(); VBox box = new VBox(); box.layoutYProperty().bind(bar.valueProperty());
scrollBar.setMin(scrollBar1.getMin()); scrollBar.setMax(scrollBar1.getMax()); scrollBar.valueProperty().bindBidirectional(scrollBar1.valueProperty()); scrollBar.valueProperty().bindBidirectional(scrollBar2.valueProperty());
@Override protected void layoutChildren() { double layoutWidth = getLayoutBounds().getWidth(); double layoutHeight = getLayoutBounds().getHeight(); boolean vbarVisible = vbar.isVisible(); boolean hbarVisible = hbar.isVisible(); double vbarWidth = vbarVisible ? vbar.prefWidth(-1) : 0; double hbarHeight = hbarVisible ? hbar.prefHeight(-1) : 0; double w = layoutWidth - vbarWidth; double h = layoutHeight - hbarHeight; content.resize(w, h); hbar.setVisibleAmount(w); vbar.setVisibleAmount(h); if(vbarVisible) { vbar.resizeRelocate(layoutWidth - vbarWidth, 0, vbarWidth, h); } if(hbarVisible) { hbar.resizeRelocate(0, layoutHeight - hbarHeight, w, hbarHeight); } }
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()); } } });
@Override protected double computeValue() { double max = bar.getMax(); double visible = bar.getVisibleAmount(); return max > visible ? 16 / (max - visible) * max : 0; } });
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); } });
hbar = new ScrollBar(); vbar = new ScrollBar(); hbar.setOrientation(Orientation.HORIZONTAL); vbar.setOrientation(Orientation.VERTICAL); hbar.setMin(0); vbar.setMin(0); hbar.maxProperty().bind(content.totalWidthEstimateProperty()); vbar.maxProperty().bind(content.totalHeightEstimateProperty()); hbar.blockIncrementProperty().bind(hbar.visibleAmountProperty()); vbar.blockIncrementProperty().bind(vbar.visibleAmountProperty()); .orElseConst(0.0) .asVar(this::setVPosition); hbarValue = Var.doubleVar(hbar.valueProperty()); vbarValue = Var.doubleVar(vbar.valueProperty()); Bindings.bindBidirectional(hbarValue, hPosEstimate); Bindings.bindBidirectional(vbarValue, vPosEstimate); needsVBar0, content.totalWidthEstimateProperty(), vbar.widthProperty(), layoutWidth, (needsH, needsV, cw, vbw, lw) -> needsH || needsV && cw + vbw.doubleValue() > lw); needsHBar0, content.totalHeightEstimateProperty(), hbar.heightProperty(),
= scrollBar.maxProperty().subtract(scrollBar.minProperty()).multiply(pos).add(scrollBar.minProperty()); ); scrollBar.visibleProperty().addListener((observable, wasVisible, isVisible) -> { if (!isVisible) { timeline.statusProperty().addListener((observable, oldStatus, newStatus) -> { if (newStatus == Animation.Status.RUNNING) { scrollBar.setDisable(true); scrollBar.valueProperty().bind(scrollValueBinding); } else if (oldStatus == Animation.Status.RUNNING) { scrollBar.setDisable(false); scrollBar.valueProperty().unbind(); if (timeline.getStatus() == Animation.Status.RUNNING || !scrollBar.isVisible()) { timeline.pause(); } else { timeline.playFrom(total.multiply((scrollBar.getValue() - scrollBar.getMin()) / (scrollBar.getMax() - scrollBar.getMin())));
final ScrollBar sc = new ScrollBar(); root.getChildren().addAll(anchorPane, sc); sc.setLayoutX(scene.getWidth()- sc.getWidth()/2 - 1); sc.setMin(0); sc.setOrientation(Orientation.VERTICAL); sc.setPrefHeight(sceneH); sc.setMax(preHeight - sceneH); sc.setVisible(false); public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { sc.setLayoutX(arg2.doubleValue()- sc.getWidth()/2 - 1); anchorPane.setPrefWidth(arg2.doubleValue() - sc.getWidth()); public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { sc.setMax(preHeight - arg2.doubleValue()); if(arg2.doubleValue() >= preHeight) { sc.setVisible(false); sc.setVisible(true); sc.setPrefHeight(arg2.doubleValue()); anchorPane.setPrefHeight(arg2.doubleValue()); sc.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov,
ScrollBar scrollBar = new ScrollBar(); scrollBar.setMin(0); scrollBar.setMax(TOTAL_WIDTH - canvas.getWidth()); scrollBar.setVisibleAmount(scrollBar.getMax() * canvas.getWidth() / TOTAL_WIDTH); draw(canvas, scrollBar.getValue()); scrollBar.valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { draw(canvas, scrollBar.getValue());
scrollPane.setContent(pane); ScrollBar vScrollBar = new ScrollBar(); vScrollBar.setOrientation(Orientation.VERTICAL); vScrollBar.minProperty().bind(scrollPane.vminProperty()); vScrollBar.maxProperty().bind(scrollPane.vmaxProperty()); vScrollBar.visibleAmountProperty().bind(scrollPane.heightProperty().divide(pane.heightProperty())); scrollPane.vvalueProperty().bindBidirectional(vScrollBar.valueProperty()); ScrollBar hScrollBar = new ScrollBar(); hScrollBar.setOrientation(Orientation.HORIZONTAL); hScrollBar.minProperty().bind(scrollPane.hminProperty()); hScrollBar.maxProperty().bind(scrollPane.hmaxProperty()); hScrollBar.visibleAmountProperty().bind(scrollPane.widthProperty().divide(pane.heightProperty())); scrollPane.hvalueProperty().bindBidirectional(hScrollBar.valueProperty()); stage.show(); vScrollBar.requestLayout(); hScrollBar.requestLayout();
@Override public void start(Stage primaryStage) { ScrollBar scrollBar = new ScrollBar(); scrollBar.setOrientation(Orientation.VERTICAL); scrollBar.setMax(100); scrollBar.setVisibleAmount(50); scrollBar.valueProperty().addListener((a,b,c) -> System.out.println(c)); StackPane root = new StackPane(); root.getChildren().add(scrollBar); Scene scene = new Scene(root, 200, 500); // do layout root.applyCss(); root.layout(); ScrollBarMark mark1 = new ScrollBarMark(); ScrollBarMark mark2 = new ScrollBarMark(); mark1.attach(scrollBar); mark2.attach(scrollBar); mark1.setPosition(50); mark2.setPosition(75); primaryStage.setScene(scene); primaryStage.show(); }
public void bindHorizontalScrollbar(ScrollBar bar) { bar.setMin(0); DoubleBinding max = this.contentBody.widthProperty().subtract(widthProperty()); DoubleBinding factor = this.contentBody.widthProperty().divide(max); bar.maxProperty().bind(this.contentBody.widthProperty().divide(factor)); bar.visibleAmountProperty().bind(widthProperty().divide(factor)); this.offsetX.bind(bar.valueProperty()); }
public void bind(ScrollBar bar) { bar.minProperty().bind(this.min); bar.maxProperty().bind(this.max); bar.visibleAmountProperty().bind(this.contentAreaHeight.divide(this.contentHeight.divide(this.max))); bar.valueProperty().bindBidirectional(this.offset); recomputeAll(); }
public AquaScrollBarSkin(ScrollBar scrollBar) { super(scrollBar); if (getNode().getParent() instanceof ScrollPane) { fadeable = true; } scrollBar.setVisible(!fadeable); registerChangeListener(scrollBar.hoverProperty(), "HOVER"); registerChangeListener(scrollBar.valueProperty(), "VALUE"); registerChangeListener(scrollBar.visibleProperty(), "VISIBLE"); }
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); } }
if (n2 instanceof ScrollBar) { final ScrollBar bar2 = (ScrollBar) n2; bar1.valueProperty().bindBidirectional(bar2.valueProperty());
public ScrollbarPane() { this.horizontal = new ScrollBar(); this.horizontal.setOrientation(Orientation.HORIZONTAL); this.vertical = new ScrollBar(); this.vertical.setOrientation(Orientation.VERTICAL); this.clip = new Rectangle(); getChildren().setAll(this.horizontal, this.vertical); }
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; } }});
&& ((verticalBar.getMinimum() == 0 && verticalBar.getMaximum() == 0 && verticalBar.getSelection() == 0) || !verticalBar.isEnabled() || !verticalBar .isVisible()) ) { msg = WM_HSCROLL;