本文整理汇总了Java中javafx.scene.control.Slider.setPrefWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Slider.setPrefWidth方法的具体用法?Java Slider.setPrefWidth怎么用?Java Slider.setPrefWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Slider
的用法示例。
在下文中一共展示了Slider.setPrefWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FanOptionPane
import javafx.scene.control.Slider; //导入方法依赖的package包/类
public FanOptionPane()
{
super();
super.getStyleClass().add("hbox");
super.setPadding(new Insets(10,10,10,10));
super.setSpacing(10);
speedSlider = new Slider(10, 100, InstanceProvider.getFanManager().getManaulSpeed());
speedSlider.setPrefWidth(435);
speedSlider.valueProperty().addListener(new SpeedSliderListener());
Space sep = new Space();
sep.setMinWidth(3);
sep.setMaxWidth(3);
sep.setMinHeight(25);
sep.setMaxHeight(25);
modes = new ComboBox<>(FXCollections.observableArrayList("Auto", "Manual"));
modes.getSelectionModel().selectedItemProperty().addListener(new ModeHandler());
modes.getSelectionModel().select(InstanceProvider.getFanModeController().getCurrentValue());
modeBox = new HBox();
modeBox.setSpacing(8);
modeBox.getChildren().addAll(new Label("Fan Mode:"), modes);
speedBox = new HBox();
speedBox.setSpacing(8);
speedBox.getChildren().addAll(sep, new Label("Manual Speed:"), speedSlider);
super.getChildren().addAll(modeBox, speedBox);
}
示例2: SoundPlayer
import javafx.scene.control.Slider; //导入方法依赖的package包/类
/**
* Creates: a new sound player
*/
public SoundPlayer() {
play = new ToggleButton(PLAY);
play.selectedProperty().addListener((s, o, n) -> {
// If we have a player
if (player != null) {
if (n.booleanValue()) {
play.setText(PAUSE);
player.play();
} else {
play.setText(PLAY);
player.pause();
}
} else {
play.setSelected(false);
}
});
play.setFont(fontAwesome);
play.setPrefWidth(MEDIUM_WIDTH);
getChildren().add(play);
HBox.setHgrow(play, Priority.NEVER);
Label mute = new Label("\uf026");
Label loud = new Label("\uf028");
mute.setFont(fontAwesome);
loud.setFont(fontAwesome);
mute.setPrefWidth(SMALL_WIDTH);
loud.setPrefWidth(SMALL_WIDTH);
volume = new Slider(0, 1, 1);
volume.setPrefWidth(BIG_WIDTH);
mute.setAlignment(Pos.BASELINE_RIGHT);
getChildren().add(mute);
getChildren().add(volume);
getChildren().add(loud);
passed = new Label("00:00");
passed.setAlignment(Pos.BASELINE_RIGHT);
remaining = new Label("00:00");
passed.setPrefWidth(MEDIUM_WIDTH);
remaining.setPrefWidth(MEDIUM_WIDTH);
progress = new ProgressBar(0);
progress.setMaxWidth(Double.MAX_VALUE);
getChildren().add(passed);
HBox.setHgrow(passed, Priority.NEVER);
getChildren().add(progress);
HBox.setHgrow(progress, Priority.ALWAYS);
getChildren().add(remaining);
HBox.setHgrow(remaining, Priority.NEVER);
setAlignment(Pos.CENTER_LEFT);
setSpacing(10);
setMaxHeight(USE_PREF_SIZE);
setPadding(new Insets(10));
clear();
}
示例3: turtleSpeedSlider
import javafx.scene.control.Slider; //导入方法依赖的package包/类
private VBox turtleSpeedSlider () {
VBox container = new VBox();
HBox row = new HBox();
final Slider slider = new Slider(1, 1000, 50);
slider.setPrefWidth(400);
Label text = new Label(Integer.toString((int) slider.getValue()));
slider.valueProperty().addListener( (obs, old, newValue) -> {
long speed = Math.round((double) newValue);
text.setText(Long.toString(speed));
view.setTurtleSpeed(25000/((double) newValue));
});
row.getChildren().addAll(slider, text);
container.getChildren().addAll(new Label("Select turtle speed"),
row);
return container;
}
示例4: MediaBar
import javafx.scene.control.Slider; //导入方法依赖的package包/类
public MediaBar() {
setAlignment(Pos.CENTER);
setPadding(new Insets(5, 10, 5, 10));
setSpacing(10);
Label timeLabel = new Label("Time: ");
Label volumeLabel = new Label("Vol: ");
playButton = new Button(">");
playButton.setOnAction(event -> {
switch (status) {
case PAUSED:
registeredEventHandler.play();
break;
case PLAYING:
registeredEventHandler.pause();
break;
}
});
timeSlider = new Slider();
setHgrow(timeSlider, Priority.ALWAYS);
timeSlider.setMinWidth(50);
timeSlider.setMaxWidth(Double.MAX_VALUE);
timeSlider.setOnMouseReleased(event -> registeredEventHandler.timeSliderReleased(timeSlider.getValue()));
elapsedTimeLabel = new Label("00:00/00:00");
elapsedTimeLabel.setMinWidth(50);
setMargin(elapsedTimeLabel, new Insets(0, 15, 0, 0));
volumeSlider = new Slider();
volumeSlider.setPrefWidth(70);
volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
volumeSlider.setMinWidth(30);
volumeSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
registeredEventHandler.volumeSliderChanged(oldValue.doubleValue(), newValue.doubleValue(), volumeSlider.isPressed());
});
getChildren().addAll(
playButton,
timeLabel,
timeSlider,
elapsedTimeLabel,
volumeLabel,
volumeSlider);
}