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

The following examples show how to use javafx.scene.control.Slider#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: DoubleSliderControl.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initializeParts() {
  super.initializeParts();

  fieldLabel = new Label(field.labelProperty().getValue());

  valueLabel = new Label(String.valueOf(field.getValue().doubleValue()));

  slider = new Slider();
  slider.setMin(min);
  slider.setMax(max);
  slider.setShowTickLabels(false);
  slider.setShowTickMarks(false);
  slider.setValue(field.getValue());

  node = new HBox();
  node.getStyleClass().add("double-slider-control");
}
 
Example 2
Source File: IntegerSliderControl.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initializeParts() {
  super.initializeParts();

  fieldLabel = new Label(field.labelProperty().getValue());

  valueLabel = new Label(String.valueOf(field.getValue().intValue()));

  slider = new Slider();
  slider.setMin(min);
  slider.setMax(max);
  slider.setShowTickLabels(false);
  slider.setShowTickMarks(false);
  slider.setValue(field.getValue());

  node = new HBox();
  node.getStyleClass().add("integer-slider-control");
}
 
Example 3
Source File: PercentSliderControl.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initializeParts() {
    super.initializeParts();

    fieldLabel = new Label(field.labelProperty().getValue());

    valueLabel = new Label((int) (100 * field.getValue()) + "%");

    slider = new Slider();
    slider.setMin(min);
    slider.setMax(max);
    slider.setShowTickLabels(false);
    slider.setShowTickMarks(false);
    slider.setValue(field.getValue());

    node = new HBox();
    node.getStyleClass().add("double-slider-control");
}
 
Example 4
Source File: SliderSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public SliderSample() {
    VBox root = new VBox();
    Slider slider = new Slider();
    slider.setMin(0);
    slider.setMax(100);
    slider.setValue(40);
    slider.setShowTickLabels(true);
    slider.setShowTickMarks(true);
    slider.setMajorTickUnit(50);
    slider.setMinorTickCount(5);
    slider.setBlockIncrement(10);
    root.getChildren().addAll(slider, new Button("Click me!!"));
    getChildren().add(root);
}
 
Example 5
Source File: View.java    From SynchronizeFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create an instance of the View.
 */
public View() {
    setSpacing(20);
    setPadding(new Insets(20));

    final Text header = new Text("SynchronizeFX Example");
    header.setFill(Color.DIMGRAY);
    header.setStyle("-fx-font-size:24");

    slider = new Slider();
    slider.setMin(0);
    slider.setMax(100);
    slider.setShowTickLabels(true);
    slider.setShowTickMarks(true);
    slider.setMajorTickUnit(20);
    slider.setMinorTickCount(5);
    slider.setSnapToTicks(true);


    final Label valueLabel = new Label();
    valueLabel.setTextFill(Color.DIMGRAY);
    valueLabel.setStyle("-fx-font-size:15");

    valueLabel.textProperty()
            .bind(Bindings.format("Current Value: %1$.1f",
                    slider.valueProperty()));

    getChildren().addAll(header, slider, valueLabel);
}
 
Example 6
Source File: SliderDemo.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void start(final Stage stage)
{
    final Slider slider = new Slider();
    slider.setOrientation(Orientation.HORIZONTAL);
    slider.setShowTickLabels(true);
    slider.setShowTickMarks(true);
    slider.setMajorTickUnit(20.0);
    slider.setMin(-100.0);
    slider.setMax(100.0);
    slider.setValue(10.0);

    slider.valueProperty().addListener((observable, old, value)->
    {
        System.out.println("Value: " + value);
    });

    final SliderMarkers markers = new SliderMarkers(slider);
    markers.setAlarmMarkers(-100, -10, 70, 90);

    final String font = "-fx-font-size: 30px";
    slider.setStyle(font);
    markers.setStyle(font);

    final GridPane layout = new GridPane();
    layout.add(markers, 0, 0);
    layout.getChildren().add(slider);
    if (slider.getOrientation() == Orientation.VERTICAL)
    {
        GridPane.setConstraints(slider, 1, 0);
        GridPane.setVgrow(slider, Priority.ALWAYS);
    }
    else
    {
        GridPane.setConstraints(slider, 0, 1);
        GridPane.setHgrow(slider, Priority.ALWAYS);
    }
    final Scene scene = new Scene(layout, 800, 700);
    stage.setScene(scene);
    stage.setTitle("Slider Demo");

    stage.show();
    markers.update();
}
 
Example 7
Source File: Exercise_16_18.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) {
	// Create three buttons
	Button btPause = new Button("Pause");
	Button btResume = new Button("Resume");
	Button btReverse = new Button("Reverse");

	// Create a hbox
	HBox paneForButtons = new HBox(5);
	paneForButtons.setAlignment(Pos.CENTER);
	paneForButtons.getChildren().addAll(
		btPause, btResume, btReverse);

	// Create a new FanePane
	FanPane fan = new FanPane();

	// Create a slider
	Slider slider = new Slider();
	slider.setMax(5);
	fan.rateProperty().bind(slider.valueProperty());

	// Create a pane
	BorderPane pane = new BorderPane();
	pane.setTop(paneForButtons);
	pane.setCenter(fan);
	pane.setBottom(slider);

	// Create and register handlers
	btPause.setOnAction(e -> {
		fan.pause();
	});

	btResume.setOnAction(e -> {
		fan.play();
	});

	btReverse.setOnAction(e -> {
		fan.reverse();
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 200);
	primaryStage.setTitle("Exercise_16_18"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 8
Source File: Exercise_16_19.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
/** Returns a fan pane */
public BorderPane getFan() {
	// Create three buttons
	Button btPause = new Button("Pause");
	Button btResume = new Button("Resume");
	Button btReverse = new Button("Reverse");

	// Place buttons in a hbox
	HBox paneForButtons = new HBox(5);
	paneForButtons.getChildren().addAll(btPause, btResume, btReverse);

	// Create a fan pane
	FanPane fan = new FanPane();

	// Create a slider and set its properties
	Slider slider = new Slider();
	slider.setMax(5);
	fan.rateProperty().bind(slider.valueProperty());

	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setStyle("-fx-border-color: black");
	pane.setTop(paneForButtons);
	pane.setCenter(fan);
	pane.setBottom(slider);

	// Create and register the handlers
	btPause.setOnAction(e -> {
		fan.pause();
	});

	btResume.setOnAction(e -> {
		fan.play();
	});

	btReverse.setOnAction(e -> {
		fan.reverse();
	});

	return pane;
}
 
Example 9
Source File: DemoUtil.java    From RadialFx with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void addAngleControl(final String title, final DoubleProperty prop) {
final Slider slider = addSliderControl(title, prop);
slider.setMin(0);
slider.setMax(360);
   }
 
Example 10
Source File: DemoUtil.java    From RadialFx with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void addRadiusControl(final String title, final DoubleProperty prop) {
final Slider slider = addSliderControl(title, prop);
slider.setMin(0);
slider.setMax(500);
   }