menuItemが選択されているときに現在のシーンを閉じて別のシーンを開くときに問題があります。私のメインステージは以下のようにコーディングされていますjavaFXの切り替えシーン
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Shop Management");
Pane myPane = (Pane)FXMLLoader.load(getClass().getResource
("createProduct.fxml"));
Scene myScene = new Scene(myPane);
primaryStage.setScene(myScene);
primaryStage.show();
}
のmenuItemはonclickのときに続いてcreateProduct.fxml以内に、それは、これを実行します。
public void gotoCreateCategory(ActionEvent event) throws IOException {
Stage stage = new Stage();
stage.setTitle("Shop Management");
Pane myPane = null;
myPane = FXMLLoader.load(getClass().getResource("createCategory.fxml"));
Scene scene = new Scene(myPane);
stage.setScene(scene);
stage.show();
}
それはcreateCategory.fxmlを開いありません。ただし、createProduct.fxmlの前のパネルは閉じません。これを行うにはstage.close()というものがあることはわかっていますが、最初からメインの右からシーンを渡さないので、どこで実装するかわかりません。私はこれをどのように修正すべきか疑問に思います。
ありがとうございます。
新しいステージで別の画面(createCategory.fxml)を開く必要がありますか? –
私はあなたがJframeを知っているようにやろうとしていますか? getJFrame()。dispose(); \t \t \t \t \t eForumForgotPwd myWindow = new eForumForgotPwd(); \t \t \t \t \t \t \t myWindow.getJFrame()のsetVisible(TRUE)。新しいウィンドウを開く前に現在のウィンドウを閉じる必要があります –