我试图根据用户在前一场景中选择的按钮在某个场景中显示不同的内容。我尝试使用public static void main(String[] args)
和计时器来实现这一点,但我不能。
如何在场景打开时运行contentSelect()? 我知道这应该很简单,但我不能让它为我的生活而工作。
package application;
import java.time.Duration;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
public class GrammarTestController {
private static int picSelect=0;
@FXML
private Label title;
@FXML
private Label info;
@FXML
private ImageView image;
//Will decide which type of content to display
private void contentSelect(){
}
}
答案 0 :(得分:0)
实施Initializable
:
public class GrammarTestController implements Initializable{
private static int picSelect=0;
@FXML
private Label title;
@FXML
private Label info;
@FXML
private ImageView image;
//This method is called upon fxml load
public void initialize(URL location, ResourceBundle resources) {
contentSelect();
}
//Will decide which type of content to display
private void contentSelect(){
}
}