###起こっていること
次のようなコードをかきました.
Java
1class KoWnd extends Stage { 2 3 public KoWnd(Window wnd){ 4 this.initOwner(wnd); 5 this.initModality(Modality.APPLICATION_MODAL); 6 this.setResizable(false); 7 this.setWidth(240); 8 this.setHeight(200); 9 this.setAlwaysOnTop(true); 10 11 Label lbl = new Label(); 12 lbl.setFont(new Font(24)); 13 lbl.setText("これは子ウィンドウ"); 14 15 Button btnClose = new Button("Close"); 16 btnClose.setPrefWidth(80); 17 btnClose.setOnAction(event -> this.close()); 18 19 VBox root = new VBox(); 20 root.setAlignment(Pos.CENTER); 21 root.getChildren().addAll(lbl,btnClose); 22 23 this.setScene(new Scene(root)); 24 } 25}
Java
1public class OyaWnd extends Application { 2 3 @Override 4 public void start(Stage stage) throws Exception { 5 6 Stage child= new KoWnd(stage); 7 child.show(); 8 9 stage.setTitle("Teratail"); 10 stage.setWidth(300); 11 stage.setHeight(250); 12 13 Label lblMsg = new Label("これは親ウィンドウ"); 14 lblMsg.setFont(new Font(30)); 15 16 Button btnChild = new Button("子ウィンドウを開く"); 17 btnChild.setOnAction(event -> child.show()); 18 19 Button btnOk = new Button("OK"); 20 btnOk.setPrefWidth(80); 21 btnOk.setOnAction(event -> stage.close()); 22 23 VBox root = new VBox(); 24 root.setAlignment(Pos.CENTER); 25 root.setPadding(new Insets(10,10,10,10)); 26 root.setSpacing(20); 27 root.getChildren().addAll(lblMsg,btnChild,btnOk); 28 29 stage.setScene(new Scene(root)); 30 stage.show(); 31 32 } 33}
ソースの初めのchild.show(); で子ウィンドウを表示したときは,親ウィンドウを操作することができますが,
btnChildでchild.show(); を呼び出した場合は,親ウィンドウを操作できません.
###質問
1.なぜ,同じchild.show();に違いが出ているのか.
2.一回目でも,意図的に親ウィンドウを操作できなくすることは可能か.
3.btnChildを押されたときに呼び出すchild.show(); でも意図的に親ウィンドウを操作できるようにすることは可能か.
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/08/29 23:04