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

The following examples show how to use javafx.scene.control.Slider#setValue() . 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: DemoUtil.java    From RadialFx with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Slider addSliderControl(final String title,
    final DoubleProperty prop) {
final Slider slider = new Slider();
slider.setValue(prop.get());
prop.bind(slider.valueProperty());
final VBox box = new VBox();
final Text titleText = new Text(title);

titleText.textProperty().bind(new StringBinding() {
    {
	super.bind(slider.valueProperty());
    }

    @Override
    protected String computeValue() {
	return title + " : " + twoDForm.format(slider.getValue());
    }

});
box.getChildren().addAll(titleText, slider);
getChildren().add(box);
return slider;
   }
 
Example 5
Source File: ColourBackground.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) {
    backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("color.theme.label"));
    backgroundColorPicker.setValue(getColour());
    backgroundLocation.clear();
    backgroundVidLocation.clear();
    vidHueSlider.setValue(0);
    vidStretchCheckbox.setSelected(false);
}
 
Example 6
Source File: ImageBackground.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundImgLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) {
    backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("image.theme.label"));
    backgroundImgLocation.setText(imageName);
    backgroundColorPicker.setValue(Color.BLACK);
    backgroundColorPicker.fireEvent(new ActionEvent());
    backgroundVidLocation.clear();
    vidHueSlider.setValue(0);
    vidStretchCheckbox.setSelected(false);
}
 
Example 7
Source File: VideoBackground.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundImgLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) {
    backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("video.theme.label"));
    backgroundVidLocation.setText(getVideoFile().getName());
    vidHueSlider.setValue(hue);
    vidStretchCheckbox.setSelected(stretch);
    backgroundColorPicker.setValue(Color.BLACK);
    backgroundColorPicker.fireEvent(new ActionEvent());
    backgroundImgLocation.clear();
}
 
Example 8
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 9
Source File: SliderGlitchDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("nls")
@Override
public void start(final Stage stage)
{
    Slider slider = new Slider();
    slider.setOrientation(Orientation.VERTICAL);
    slider.setLayoutX(110);
    slider.setPrefHeight(200);
    slider.setValue(Double.NaN);

    Rectangle rect1 = createRect(10);
    rect1.setStyle("-fx-stroke-width: 1; -fx-stroke-dash-array: 5.0, 5.0; -fx-stroke: blue; -fx-fill: rgb(0, 0, 255, 0.05);");

    Rectangle rect2 = createRect(30);
    rect2.setStyle("-fx-stroke-width: 1; -fx-stroke: blue; -fx-fill: rgb(0, 0, 255, 0.05);");

    final Pane pane = new Pane(slider, rect1, rect2);
    pane.setPadding(new Insets(5));

    final Label label = new Label("Drag the bottom right corner of each rectangle across the slider. When the slider value is NaN,\n"
            + "the dashed rectangle freezes the program; the solid-bordered one disappears and reappears.\n"
            + "When it is finite, the rectangles behave as expected.");
    
    Button button = new Button("Toggle NaN/finite value.");
    button.setOnAction(e->
    {
        slider.setValue(Double.isFinite(slider.getValue()) ? Double.NaN : 50);
    });

    final VBox root = new VBox(pane, label, button);
    final Scene scene = new Scene(root, 800, 700);

    stage.setScene(scene);
    stage.setTitle("Slider Glitch Demo");

    stage.show();
}
 
Example 10
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();
}