0
点赞
收藏
分享

微信扫一扫

JavaFX 窗口的 模态 父窗口 弹出子窗口 父窗口不可以编辑

彩虹_bd07 2023-02-01 阅读 66

package fx.com;

import javafx.application.Application;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class Main extends Application {
public static void main(String[] args) {
launch(Main.class,args);
}
@Override
public void start(Stage primaryStage){
Stage s1 = new Stage();
s1.setTitle("1");

Stage s2 = new Stage();
s2.setTitle("2");
s2.initOwner(s1);//s2 一直在 s1 的上面
//s2 不关闭 s1 不能操作
// s2.initModality(Modality.WINDOW_MODAL);

Stage s3 = new Stage();
s3.setTitle("3");
//s3 不关闭 s2 和 s1 就不可以点击
s3.initModality(Modality.APPLICATION_MODAL);


s1.show();
s2.show();
s3.show();
}
}

举报

相关推荐

0 条评论