本文整理汇总了Java中javafx.scene.control.Slider.setSnapToTicks方法的典型用法代码示例。如果您正苦于以下问题:Java Slider.setSnapToTicks方法的具体用法?Java Slider.setSnapToTicks怎么用?Java Slider.setSnapToTicks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Slider
的用法示例。
在下文中一共展示了Slider.setSnapToTicks方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSliderRange
import javafx.scene.control.Slider; //导入方法依赖的package包/类
static void setSliderRange(final Slider slider, double position, double min, double max) {
slider.setMin(min);
slider.setMax(max);
// int range = (int)(max - min + 0.5);
// if (range > 200) {
// slider.setMajorTickUnit(50);
// slider.setMinorTickCount(10);
// } else if (range >= 50) {
// slider.setMajorTickUnit(10);
// slider.setMinorTickCount(5);
// } else if (range >= 10) {
// slider.setMajorTickUnit(5);
// slider.setMinorTickCount(1);
// } else {
// slider.setMajorTickUnit(1);
// slider.setMinorTickCount(1);
// }
slider.setMajorTickUnit(1);
slider.setSnapToTicks(true);
slider.setShowTickMarks(false);
slider.setShowTickLabels(false);
slider.setValue(position);
slider.setOpacity(0.25);
slider.setBlockIncrement(1.0);
slider.setOnMouseEntered(e -> {
slider.setOpacity(1);
});
slider.setOnMouseExited(e -> {
slider.setOpacity(0.5);
});
}
示例2: prepareSlider
import javafx.scene.control.Slider; //导入方法依赖的package包/类
private void prepareSlider() {
slider = new Slider(0, nbIteration, 5);
slider.setMajorTickUnit(nbIteration);
slider.valueProperty().addListener((ov, oldVal, newVal) -> {
long lNewVal = newVal.longValue();
if(lNewVal != oldVal.longValue())
System.out.println(lNewVal);
});
slider.setBlockIncrement(1);
slider.setSnapToTicks(true);
if(nbIteration > Integer.MAX_VALUE) {
slider.setMinorTickCount(Integer.MAX_VALUE);
} else
slider.setMinorTickCount((int) nbIteration - 1);
// slider.setShowTickLabels(true);
// slider.setShowTickMarks(true);
}
示例3: newSlider
import javafx.scene.control.Slider; //导入方法依赖的package包/类
public static Slider newSlider(final double min, final double max, final double value, final double blockIncrement, final double majorTickUnit, final boolean showTickLabels, final boolean showTickMarks, final boolean snapToTicks, ChangeListener<? super Number> changeListener) {
final
Slider slider = new Slider(min, max, value);
slider.setBlockIncrement(blockIncrement);
slider.setMajorTickUnit(majorTickUnit);
slider.setShowTickLabels(showTickLabels);
slider.setShowTickMarks(showTickMarks);
slider.setSnapToTicks(snapToTicks);
slider.valueProperty().addListener(changeListener);
return slider;
}
示例4: createSlider
import javafx.scene.control.Slider; //导入方法依赖的package包/类
private Slider createSlider(){
Slider pSlider = new Slider();
pSlider.setShowTickLabels(true);
pSlider.setShowTickMarks(true);
pSlider.setSnapToTicks(true);
pSlider.setMin(0);
pSlider.setMax(10.0);
pSlider.setMajorTickUnit(10.0);
pSlider.setMinorTickCount(99);
pSlider.setBlockIncrement(0.1);
return pSlider;
}
示例5: SliderEditor
import javafx.scene.control.Slider; //导入方法依赖的package包/类
public SliderEditor(Option<Number> option, int min, int max) {
slider = new Slider(min, max, option.valueProperty().getValue().doubleValue());
slider.setSnapToTicks(true);
slider.setMajorTickUnit(1);
slider.setMinorTickCount(0);
valueProperty().bindBidirectional(option.valueProperty());
}
示例6: getContent
import javafx.scene.control.Slider; //导入方法依赖的package包/类
private Parent getContent() {
final Slider slider = new Slider();
slider.setMin(0);
slider.setMax(100);
slider.setShowTickMarks(true);
slider.setBlockIncrement(1);
slider.setMajorTickUnit(1);
slider.setSnapToTicks(true);
String duration = "3000ms"; // Change this value for different speeds
final Timeline timeline = new Timeline();
timeline.setCycleCount(1);
KeyValue kv = new KeyValue(slider.valueProperty(),100);
KeyFrame kf = new KeyFrame(Duration.valueOf(duration), kv);
timeline.getKeyFrames().add(kf);
Button button = new Button("Button");
button.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
timeline.play();
}
});
VBox vbox = new VBox(5);
vbox.getChildren().addAll(slider, button);
return vbox;
}
示例7: View
import javafx.scene.control.Slider; //导入方法依赖的package包/类
/**
* 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);
}