I have a window that has 2 scenes that i need to change between when i click a button. I am having issues trying to think of ways to efficiently change scenes from the controller for the FXML document. Is there a method to do this with javafx like this.getScene().getStage() or something along those lines?
Your controller has most likely access to a Node (eg Button) the you can do
@FXML
Button b;
...
@FXML
public void flip() {
Stage s = (Stage)b.getScene().getWindow();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.