如何返回上一场景

时间:2019-04-05 07:07:31

标签: javafx scenebuilder

我正在用javafx scenebuilder制作3个场景。

Scene A: Edit Record -> Scene C

Scene B: View Record -> Scene C

Scene C: View Data

如何在不创建重复场景C的情况下返回上一个场景(A或B)。

public void view(ActionEvent event) throws IOException{
    Parent mainpanelForm = FXMLLoader.load(getClass().getResource("Scene A or Scene B file location"));
    Scene mainpanelUI = new Scene(mainpanelForm);                 
    Stage mainpanel = (Stage) ((Node)event.getSource()).getScene().getWindow();  
    mainpanel.setScene(mainpanelUI);
    mainpanel.centerOnScreen();     
    mainpanel.setMaximized(true);
    mainpanel.show(); 
}

0 个答案:

没有答案