本文整理匯總了Java中javafx.scene.control.Slider.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Slider.setValue方法的具體用法?Java Slider.setValue怎麽用?Java Slider.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Slider
的用法示例。
在下文中一共展示了Slider.setValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: VisionControl
import javafx.scene.control.Slider; //導入方法依賴的package包/類
public VisionControl() {
slider = new Slider();
slider.setMin(0.0);
slider.setMax(255.0);
slider.setValue(0.0);
slider.setMaxWidth(350.0);
slider.setDisable(true);
inputText = new TextField();
inputText.setText("0");
inputText.setMaxWidth(50.0);
inputText.setOnKeyPressed((e)->{
if(e.getCode() == KeyCode.ENTER){
setTextFromField();
}
});
inputText.focusedProperty().addListener((obs, o, n)->{
if(!n.booleanValue()){
inputText.setText(String.valueOf((int)slider.getValue()));
}
});
slider.valueProperty().addListener((obs, o, n)->{
inputText.setText(String.valueOf((int)slider.getValue()));
});
nameLabel = new Label("");
HBox top = new HBox();
top.setSpacing(5.0);
top.getChildren().addAll(nameLabel, inputText);
VBox all = new VBox();
all.setSpacing(10.0);
all.getChildren().addAll(top, slider);
root = all;
}
示例2: drawNode
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
public Node drawNode() {
Slider slider = createSlider(min, max, vertical);
slider.setValue(value);
if (value > slider.getMax()) {
value = slider.getMax();
}
if (value < slider.getMin()) {
value = slider.getMin();
}
if (Double.compare(slider.getMin(), min) != 0) {
reportGetterFailure("Slider.getMin()");
}
if (Double.compare(slider.getMax(), max) != 0) {
reportGetterFailure("Slider.getMax()");
}
if (Double.compare(slider.getValue(), value) != 0) {
reportGetterFailure("Slider.getValue()");
}
return slider;
}
示例3: 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);
});
}
示例4: createSlider
import javafx.scene.control.Slider; //導入方法依賴的package包/類
private Slider createSlider(double chartUpperDefault, double chartUpperBound, double chartTickUnit) {
Slider slider = new Slider();
slider.setOrientation(Orientation.VERTICAL);
slider.setMin(0);
slider.setMax(chartUpperBound);
slider.setValue(chartUpperDefault);
slider.setShowTickLabels(true);
slider.setShowTickMarks(true);
slider.setMajorTickUnit(chartTickUnit);
//slider.setMinorTickCount(0.01);
slider.setBlockIncrement(0.01);
// otherwise below, we also could delegate mediator, but in this case
// it is unnecessary because if the GUI that interacts with itself
//slider.valueProperty().addListener(mediator);
return slider;
}
示例5: createSlider
import javafx.scene.control.Slider; //導入方法依賴的package包/類
private Slider createSlider() {
Slider slider = new Slider();
slider.setOrientation(Orientation.VERTICAL);
slider.setMin(1);
slider.setMax(10);
slider.setValue(1);
slider.setShowTickLabels(true);
slider.setShowTickMarks(true);
slider.setMajorTickUnit(0.5);
//slider.setMinorTickCount(0.01);
slider.setBlockIncrement(0.01);
slider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov,
Number old_val, Number new_val) {
magnificationProperty.set(new_val.doubleValue());
}
});
// otherwise below, we also could delegate mediator, but in this case
// it is unnecessary because if the GUI that interacts with itself
//slider.valueProperty().addListener(mediator);
return slider;
}
示例6: addSliderControl
import javafx.scene.control.Slider; //導入方法依賴的package包/類
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;
}
示例7: SliderSample
import javafx.scene.control.Slider; //導入方法依賴的package包/類
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);
}
示例8: pitchChanged
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
public void pitchChanged(final Camera camera, final Angle pitch) {
final Slider sliderPitch = this.sliderPitch;
if(sliderPitch != null) {
if(Platform.isFxApplicationThread()) {
sliderPitch.setValue(pitch.degrees);
} else {
Platform.runLater(() -> sliderPitch.setValue(pitch.degrees));
}
}
}
示例9: yawChanged
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
public void yawChanged(final Camera camera, final Angle yaw) {
final Slider sliderYaw = this.sliderYaw;
if(sliderYaw != null) {
if(Platform.isFxApplicationThread()) {
sliderYaw.setValue(yaw.degrees);
} else {
Platform.runLater(() -> sliderYaw.setValue(yaw.degrees));
}
}
}
示例10: createSlider
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
public Slider createSlider (double min, double max, double start, double increment) {
Slider slider = new Slider();
slider.setMin(min);
slider.setMax(max);
slider.setValue(start);
slider.setBlockIncrement(increment);
slider.setShowTickLabels(true);
slider.setShowTickMarks(true);
return slider;
}
示例11: ProgressSlider
import javafx.scene.control.Slider; //導入方法依賴的package包/類
public ProgressSlider(int minWidth, int minHeight, int maxWidth, int maxHeight) {
progressBar = new ProgressBar();
progressBar.setProgress(0D);
slider = new Slider();
slider.setValue(1);
slider.setValue(0);
if(minWidth != -1) this.setMinWidth(minWidth);
if(maxWidth != -1) this.setMaxWidth(maxWidth);
if(minHeight != -1) this.setMinHeight(minHeight);
if(maxHeight != -1) this.setMaxHeight(maxHeight);
progressBar.prefWidthProperty().bind(this.widthProperty());
slider.prefWidthProperty().bind(this.widthProperty());
slider.prefHeightProperty().bind(this.heightProperty());
this.heightProperty().addListener((observeable, oldValue, newValue) -> {
progressBar.prefHeightProperty().set(newValue.doubleValue() / 6);
});
slider.valueProperty().addListener((observeable, oldValue, newValue) -> {
double progress = newValue.doubleValue() / slider.getMax();
progressBar.setProgress(progress);
});
this.getChildren().add(progressBar);
this.getChildren().add(slider);
progressBar.getStyleClass().add("slider_Progress");
slider.getStyleClass().add("slider_Slider");
}
示例12: setUpSlider
import javafx.scene.control.Slider; //導入方法依賴的package包/類
/**
* Sets up one Slider and is used multiple times to do it for more sliders. Also handles what the sliders do
* TODO perhaps add the same parameters like setUpSpinner() to have save min and max because while the values stick to the
* rules of setUpSpinner it can show funny stuff if not correctly done in FXML
* @param slider
* @param val
* @param pos
*/
private void setUpSlider(Slider slider, int pos, double savedSet){
slider.setValue(savedSet);
slider.valueProperty().addListener((observable, oldValue, newValue) -> {
System.out.println("Slider Value Changed (newValue in Integer: " + newValue.intValue() + ")");
setValueSettings(pos, newValue);
});
}
示例13: start
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@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();
}
示例14: mainScreen
import javafx.scene.control.Slider; //導入方法依賴的package包/類
private void mainScreen(final Stage primaryStage) {
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Text scenetitle = new Text("Game Of Life");
scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
grid.add(scenetitle, 0, 0);
Label heightLabel = new Label("Height:");
grid.add(heightLabel, 0, 2);
final TextField heightField = new TextField();
heightField.setText(String.valueOf(fieldHeight));
grid.add(heightField, 1, 2);
Label widthLabel = new Label("Width:");
grid.add(widthLabel, 0, 3);
final TextField widthField = new TextField();
widthField.setText(String.valueOf(fieldWidth));
grid.add(widthField, 1, 3);
Label cellDensityLabel = new Label("Cell density:");
grid.add(cellDensityLabel, 0, 4);
final Slider cellDensitySlider = new Slider();
cellDensitySlider.setMin(0);
cellDensitySlider.setMax(1);
cellDensitySlider.setValue(cellDensity);
cellDensitySlider.setShowTickLabels(true);
cellDensitySlider.setShowTickMarks(true);
cellDensitySlider.setMajorTickUnit(0.50);
cellDensitySlider.setMinorTickCount(10);
grid.add(cellDensitySlider, 1, 4);
final Label errorLabel = new Label("");
errorLabel.setMinSize(150, 10);
grid.add(errorLabel, 0, 6);
Button start = new Button("Start");
start.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
fieldHeight = Integer.parseInt(heightField.getText());
fieldWidth = Integer.parseInt(widthField.getText());
cellDensity = cellDensitySlider.getValue();
gameScreen(primaryStage);
} catch (NumberFormatException e) {
errorLabel.setText("Please enter an integer.");
}
}
});
grid.add(start,1,5);
Scene scene = new Scene(grid);
primaryStage.setScene(scene);
}
示例15: start
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
System.out.println(FxIconics.getVersionName());
Parent root = FXMLLoader.load(getClass().getResource("showroom.fxml"));
primaryStage.setTitle("FxIconics");
primaryStage.setScene(new Scene(root, 500, 500));
primaryStage.show();
Text t_fontsize = (Text) root.lookup("#t_fontsize");
t_fontsize.setText("");
tabPane = (TabPane) root.lookup("#tabpane");
tabPaneWidth = tabPane.getWidth();
tabPane.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue) -> {
lastSelectedTab = (int) newValue;
loadTabContent(tabPane, (Integer) newValue);
});
tabPane.widthProperty().addListener((observable, oldValue, newValue) -> {
tabPaneWidth = (double) newValue;
});
loadTabContent(tabPane, 0);
Slider sliderSize = (Slider) root.lookup("#slider_size");
sliderSize.valueProperty().addListener((observable, oldValue, newValue) -> {
if (lastSliderChange + 100 < System.currentTimeMillis()) {
lastSliderChange = System.currentTimeMillis();
fontSize = newValue.intValue();
t_fontsize.setText("Font size: " + fontSize);
loadTabContent(tabPane, lastSelectedTab);
}
});
sliderSize.setValue(24);
primaryStage.widthProperty().addListener((observable, oldValue, newValue) -> {
loadTabContent(tabPane, lastSelectedTab);
});
TextField tf_search = (TextField) root.lookup("#tf_search");
tf_search.textProperty().addListener((observable, oldValue, newValue) -> {
searchFilter = newValue;
System.out.println(searchFilter);
loadTabContent(tabPane, lastSelectedTab);
});
ToolBar toolBar = (ToolBar) root.lookup("#toolbar");
FxIconicsButton btn_reset =
(FxIconicsButton) new FxIconicsButton
.Builder(FxFontGoogleMaterial.Icons.gmd_highlight_off)
.size(18)
.text("Reset", 12)
.color(MaterialColor.GREY_700).build();
btn_reset.setOnAction(event -> tf_search.setText(""));
FxIconicsButton btn_demo =
(FxIconicsButton) new FxIconicsButton
.Builder(FxFontCommunity.Icons.cmd_codepen)
.size(18)
.text("Demo", 12)
.color(MaterialColor.GREY_700).build();
btn_demo.setOnAction(event -> new DialogPlayGround());
toolBar.getItems().addAll(btn_reset, btn_demo);
}