import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.paint.Color;
import javafx.scene.control.*;
import javafx.event.ActionEvent;
import javafx.event.EventHandler; public class ModalDialog {
  Button btn;
  public ModalDialog(final Stage stg) {
  btn = new Button("OK");   final Stage stage = new Stage();
  //Initialize the Stage with type of modal
  stage.initModality(Modality.APPLICATION_MODAL);
  //Set the owner of the Stage
  stage.initOwner(stg);
  stage.setTitle("Top Stage With Modality");
  Group root = new Group();
  Scene scene = new Scene(root, 300, 250, Color.LIGHTGREEN);   btn.setOnAction(new EventHandler<ActionEvent>() {     public void handle(ActionEvent event) {
      stage.close();
}
  });   btn.setLayoutX(100);
  btn.setLayoutY(80);   root.getChildren().add(btn);
  stage.setScene(scene);
  stage.show();
  }
}
代码2:
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.stage.Stage; public class ModalTest extends Application { /**
* @param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(ModalTest.class, args);
  //    launch(args);
} @Override
public void start(final Stage primaryStage) {
  primaryStage.setTitle("Hello World");
  Group root = new Group();
  Scene scene = new Scene(root, 500, 450, Color.LIGHTBLUE);
  Button btn = new Button();
  btn.setLayoutX(250);
  btn.setLayoutY(240);
  btn.setText("Show modal dialog");
  btn.setOnAction(new EventHandler<ActionEvent>() {
    public void handle(ActionEvent event) {
    ModalDialog md = new ModalDialog(primaryStage);
    }
  });
  root.getChildren().add(btn);
  primaryStage.setScene(scene);
  primaryStage.show();
  }
}

javafx实现模态/模式窗口的更多相关文章

  1. [ucgui] 对话框7——按钮触发与模式窗口

    >_<" 模式窗口,只有结束该窗口时才能聚焦到其他的窗口上~

  2. window.open实现模式窗口

    看了些文章,实现模式窗口有两种方式.window.showModalDialog以及window.open. 一.方式介绍 window.open()支持环境: JavaScript1.0+/JScr ...

  3. 模式窗口刷新不弹出新窗口触发NET事件

    最近做项目的时候用到模式窗口,这个东西我从来没有用过,事实上我是讨厌用这个东西,由于项目需要也只好忍着了.在实现的时候发现了一个问题,打开一个模式窗口后如果里面有asp.net控件并绑定有后台事件的话 ...

  4. 创建模态提醒窗口(UIAlertView)

    UIAlertView类创建一个简单的模态提醒窗口,可能包含消息.按钮以及文本框.模态UI元素要求用户必须与之交互(通常是按下按钮)后才能做其它事情.它们通常位于其他窗口前面,在可见时禁止用户与其他任 ...

  5. Qt中的非模式窗口配置;

    Test7_5A::Test7_5A(QWidget *parent) : QMainWindow(parent){ ui.setupUi(this); m_searchwin = new Searc ...

  6. 转:模式窗口showModalDialog的用法总结

    模式窗口showModalDialog的用法总结   最近几天一直在处理模式窗口的问题,索性写了这篇总结,以供参考: 1.打开窗口:var handle = window.showModalDialo ...

  7. [WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口

    原文:[WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口 [WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口 周银辉 现象: 大家可以试试下面这个很有趣但会带来Defect的现象:当我 ...

  8. Windows 进入上帝模式窗口

    Win10上帝模式如何启用? 默认情况下,Win10的上帝模式是隐藏的,如果要开启的话,操作步骤也非常简单,下面就介绍两种方法. 方法一.直接运行命令行 1.使用[Win + R ]快捷键打开“运行” ...

  9. PyQt(Python+Qt)学习随笔:模式窗口的windowModality属性与modal属性

    windowModality属性 windowModality属性只对窗口对象有效,保存的是哪些类型的窗口被模式窗口阻塞. 模式窗口防止其他窗口中的部件获取输入.此属性的值控制对应窗口可见时阻塞哪些类 ...

随机推荐

  1. Redis模块学习笔记(一)RediSearch简单使用

    说明:安装的Redis服务器必须为 4.0 以上版本,通过info命令查看 > INFO redis_version: 一.安装 RediSearch git clone https://git ...

  2. nginx配置url中带问号的rewrite跳转

    今天收到一个需求,要将一个带查询参数的url跳转到另外一个静态url,安装常规的rewrite规则,如: rewrite ^/a.html?id=67$ http://zt.epython.cn/20 ...

  3. npm webpack工具 (监听压缩等)

    压缩.监听变动自动打包,:开发后,js编译压缩及样式去空格等 $ webpack --config XXX.js //url使用另一份配置文件(比如webpack.config2.js)来打包 $ w ...

  4. C#复杂类型序列化

    [Serializable] public class CardItemInfo { private int lineWidth;//线宽 private CardItemInfo childCard ...

  5. castle动态代理的使用

    转自:https://blog.csdn.net/educast/article/details/6565447#动态代理的原理 原理其实很简单,就是在运行时生成新的对象,姑且叫做T,并使T继承自需要 ...

  6. ELF格式探析之三:sections

    前文链接: ELF格式探析之一:Segment和Section ELF格式探析之二:文件头ELF Header详解 今天我们讲对目标文件(可重定位文件)和可执行文件都很重要的section. 我们在讲 ...

  7. DCNN models

    r egion based RNN Fast RCNN Faster RCNN F-RCN Faster RCNN the first five layers is same as the ZF ne ...

  8. luogu P1052 过河

    传送门 容易想到设\(f_i\)表示走到坐标\(i\)的最少走过的石子数 但是这题数据范围很大,,, 不过一次可以走的步数范围是1-10,石子个数最多100个,所以中间会有很多多出来的没石子的路,可以 ...

  9. Fragment add replace 区别

    首先获取FragmentTransaction对象:FragmentTransaction transaction = getFragmentManager().beginTransaction(); ...

  10. 光照问题之常见算法比较(附Python代码)

    一.灰度世界算法 ① 算法原理 灰度世界算法以灰度世界假设为基础,该假设认为:对于一幅有着大量色彩变化的图像,R,G,B三个分量的平均值趋于同一灰度值Gray.从物理意义上讲,灰色世界法假设自然界景物 ...