本文整理匯總了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);
}