Java Code Examples for javafx.scene.control.ScrollBar#setMax()

The following examples show how to use javafx.scene.control.ScrollBar#setMax() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrollBarSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private ScrollBar horizontalScrollBar(double minw, double minh, double prefw, double prefh, double maxw, double maxh) {
    final ScrollBar scrollBar = new ScrollBar();
    scrollBar.setMinSize(minw, minh);
    scrollBar.setPrefSize(prefw, prefh);
    scrollBar.setMaxSize(maxw, maxh);
    scrollBar.setVisibleAmount(50);
    scrollBar.setMax(xBarWidth-(2*circleRadius));
    return scrollBar;
}
 
Example 2
Source File: ScrollBarSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private ScrollBar verticalScrollBar(double minw, double minh, double prefw, double prefh, double maxw, double maxh) {
    final ScrollBar scrollBar = new ScrollBar();
    scrollBar.setMinSize(minw, minh);
    scrollBar.setPrefSize(prefw, prefh);
    scrollBar.setMaxSize(maxw, maxh);
    scrollBar.setVisibleAmount(50);
    scrollBar.setMax(yBarHeight-(2*circleRadius));
    return scrollBar;
}
 
Example 3
Source File: ScrollBarSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private ScrollBar horizontalScrollBar(double minw, double minh, double prefw, double prefh, double maxw, double maxh) {
    final ScrollBar scrollBar = new ScrollBar();
    scrollBar.setMinSize(minw, minh);
    scrollBar.setPrefSize(prefw, prefh);
    scrollBar.setMaxSize(maxw, maxh);
    scrollBar.setVisibleAmount(50);
    scrollBar.setMax(xBarWidth-(2*circleRadius));
    return scrollBar;
}
 
Example 4
Source File: ScrollBarSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private ScrollBar verticalScrollBar(double minw, double minh, double prefw, double prefh, double maxw, double maxh) {
    final ScrollBar scrollBar = new ScrollBar();
    scrollBar.setMinSize(minw, minh);
    scrollBar.setPrefSize(prefw, prefh);
    scrollBar.setMaxSize(maxw, maxh);
    scrollBar.setVisibleAmount(50);
    scrollBar.setMax(yBarHeight-(2*circleRadius));
    return scrollBar;
}
 
Example 5
Source File: Exercise_20_09.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	MultipleBallPane ballPane = new MultipleBallPane();
	ballPane.setStyle("-fx-border-color: yellow");

	Button btAdd = new Button("+");
	Button btSubtract = new Button("-");
	HBox hBox = new HBox(10);
	hBox.getChildren().addAll(btAdd, btSubtract);
	hBox.setAlignment(Pos.CENTER);

	// Add or remove a ball
	btAdd.setOnAction(e -> ballPane.add());
	btSubtract.setOnAction(e -> ballPane.subtract());

	// Pause and resume animation
	ballPane.setOnMousePressed(e -> ballPane.pause());
	ballPane.setOnMouseReleased(e -> ballPane.play());

	// Use a scroll bar to control animation speed
	ScrollBar sbSpeed = new ScrollBar();
	sbSpeed.setMax(20);
	sbSpeed.setValue(10);
	ballPane.rateProperty().bind(sbSpeed.valueProperty());

	BorderPane pane = new BorderPane();
	pane.setCenter(ballPane);
	pane.setTop(sbSpeed);
	pane.setBottom(hBox);

	// Create a scene and place the in the stage
	Scene scene = new Scene(pane, 250, 150);
	primaryStage.setTitle("Exercise_20_09"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 6
Source File: ScrollState.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
public void restoreState(ScrollBar scrollBar) {
    if (value > 0) {
        updateState(scrollBar);
        scrollBar.setMin(getMin());
        scrollBar.setMax(getMax());
        scrollBar.setUnitIncrement(getUnitIncrement());
        scrollBar.setBlockIncrement(getBlockIncrement());
        scrollBar.setValue(value);
    }
}
 
Example 7
Source File: Exercise_20_05.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	MultipleBallPane ballPane = new MultipleBallPane();
	ballPane.setStyle("-fx-border-color: yellow");

	// Create four buttons
	Button btSuspend = new Button("Suspend");
	Button btResume = new Button("Resume");
	Button btAdd = new Button("+");
	Button btSubtract = new Button("-");
	HBox hBox = new HBox(10);
	hBox.getChildren().addAll(
		btSuspend, btResume, btAdd, btSubtract);
	hBox.setAlignment(Pos.CENTER);

	// Add or remove a ball
	btAdd.setOnAction(e -> ballPane.add());
	btSubtract.setOnAction(e -> ballPane.subtract());
	ballPane.setOnMousePressed(e -> {
		for (Node node: ballPane.getChildren()) {
			Ball ball = (Ball)node;
			if (ball.contains(e.getX(), e.getY())) {
				ballPane.getChildren().remove(ball);
			}
		}
	});

	// Pause and resume animation
	btSuspend.setOnAction(e -> ballPane.pause());
	btResume.setOnAction(e -> ballPane.play());

	// Use a scroll bar to control animation speed
	ScrollBar sbSpeed = new ScrollBar();
	sbSpeed.setMax(20);
	sbSpeed.setValue(10);
	ballPane.rateProperty().bind(sbSpeed.valueProperty());

	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setCenter(ballPane);
	pane.setTop(sbSpeed);
	pane.setBottom(hBox);

	// Create a scene and place the in the stage
	Scene scene = new Scene(pane, 350, 200);
	primaryStage.setTitle("Exercise_20_05"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}