enter code here
我希望有一個標籤從未轉變被顯示(0.0)到正在顯示(1.0)標籤上的JavaFX淡出過渡沒有做任何事情
@FXML
private Label welcomeLabel;
public FadeTransition ft = new FadeTransition(Duration.millis(3000));
public void init(){
ft.setNode(welcomeLabel);
ft.setFromValue(0.0);
ft.setToValue(1.0);
ft.setCycleCount(1);
ft.setAutoReverse(false);
ft.play();
}
這裏是應用類
package com.ben.main;
公共類應用程序的應用延伸{
private Stage primaryStage;
private Scene loginScene;
LoginUIController loginUIController = new LoginUIController();
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
initApp();
loginUIController.init();
}
private void initApp() {
Parent root = null;
try {
root = FXMLLoader.load(getClass().getResource("loginUIFXML.fxml"));
} catch (IOException e){
System.err.println("There was an error... " + e);
}
loginScene = new Scene(root);
primaryStage.setTitle("project");
primaryStage.setResizable(false);
primaryStage.setScene(loginScene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
我還需要將它添加到現場嗎?我遇到了麻煩,現在只需輸入內容即可更新編輯。
我想1毫秒是太短,不會注意到任何更改... – jns
不,我正在測試,看看它是否會與其他值。原始值是3000,也沒有工作。 –
歡迎標籤添加到「場景」?你在哪裏調用'init'? – jns