标签:stage ide cin res listener void min rri pos
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Slider;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class App15_11 extends Application {
@Override
public void start(Stage primaryStage) {
final Slider slider = new Slider(); //创建滑动条
slider.setMin(0); //设置滑动条的最小值为0
slider.setMax(50); //设置活动条的最大值为50
final ProgressBar progressBar = new ProgressBar(); //创建不确定进度条
final ProgressIndicator progressIndicator = new ProgressIndicator(); //创建不确定进度饼图
ChangeListener<Number> changeListener = new ChangeListener<Number>(){
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
progressBar.setProgress(newValue.doubleValue()/50);
progressIndicator.setProgress(newValue.doubleValue()/50);
}
};
slider.valueProperty().addListener(changeListener);
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.setAlignment(Pos.CENTER);
hBox.getChildren().addAll(slider,progressBar,progressIndicator);
Scene scene = new Scene(hBox, 200, 100);
primaryStage.setScene(scene);
primaryStage.setTitle("键盘移动操作");
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
标签:stage ide cin res listener void min rri pos
原文地址:https://www.cnblogs.com/xl4ng/p/14406132.html