0
其實我正在創建基於菜單的程序(菜單欄,菜單,menuitem)。從每個菜單項調用新窗口就像那樣。處理當前窗口並在主窗口中加載新的fxml窗口
@FXML
private Pane rootP;
public static Pane root;
@Override
public void initialize(URL url, ResourceBundle rb) {
root = rootP;
}
@FXML
void loadWindow2Action(ActionEvent event) throws IOException {
root.getChildren().clear();
Pane newLoadedPane = (Pane) FXMLLoader.load(getClass().getResource("window2.fxml"));
root.getChildren().add(newLoadedPane);
}
現在我有一個Window2 fxml屏幕1個tableview,裏面的表我在每一行放置一個按鈕。
我的問題是如何加載新的fxml頁面和處理當前的fxml頁面,當我點擊該按鈕。
在swing中,我們簡單地配置當前的Internalframe並調用新的Internalframe。就像是 。
StdInternalFrame f = new StdInternalFrame(desktop);
this.dispose();
desktop.add(f);
這是做這
btnPay.setOnAction(e -> { try { MemberWindowController.root.getChildren().clear(); Pane newLoadedPane = (Pane)FXMLLoader.load(getClass().getResource("Window3.fxml")); MemberWindowController.root.getChildren().add(newLoadedPane); } catch (IOException ex) { Logger.getLogger(Window3Controller.class.getName()).log(Level.SEVERE, null, ex); } });
您的代碼關閉我的應用程序而不是當前窗口。 – kar