javafx实现模态/模式窗口
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实现模态/模式窗口的更多相关文章
- [ucgui] 对话框7——按钮触发与模式窗口
>_<" 模式窗口,只有结束该窗口时才能聚焦到其他的窗口上~
- window.open实现模式窗口
看了些文章,实现模式窗口有两种方式.window.showModalDialog以及window.open. 一.方式介绍 window.open()支持环境: JavaScript1.0+/JScr ...
- 模式窗口刷新不弹出新窗口触发NET事件
最近做项目的时候用到模式窗口,这个东西我从来没有用过,事实上我是讨厌用这个东西,由于项目需要也只好忍着了.在实现的时候发现了一个问题,打开一个模式窗口后如果里面有asp.net控件并绑定有后台事件的话 ...
- 创建模态提醒窗口(UIAlertView)
UIAlertView类创建一个简单的模态提醒窗口,可能包含消息.按钮以及文本框.模态UI元素要求用户必须与之交互(通常是按下按钮)后才能做其它事情.它们通常位于其他窗口前面,在可见时禁止用户与其他任 ...
- Qt中的非模式窗口配置;
Test7_5A::Test7_5A(QWidget *parent) : QMainWindow(parent){ ui.setupUi(this); m_searchwin = new Searc ...
- 转:模式窗口showModalDialog的用法总结
模式窗口showModalDialog的用法总结 最近几天一直在处理模式窗口的问题,索性写了这篇总结,以供参考: 1.打开窗口:var handle = window.showModalDialo ...
- [WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口
原文:[WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口 [WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口 周银辉 现象: 大家可以试试下面这个很有趣但会带来Defect的现象:当我 ...
- Windows 进入上帝模式窗口
Win10上帝模式如何启用? 默认情况下,Win10的上帝模式是隐藏的,如果要开启的话,操作步骤也非常简单,下面就介绍两种方法. 方法一.直接运行命令行 1.使用[Win + R ]快捷键打开“运行” ...
- PyQt(Python+Qt)学习随笔:模式窗口的windowModality属性与modal属性
windowModality属性 windowModality属性只对窗口对象有效,保存的是哪些类型的窗口被模式窗口阻塞. 模式窗口防止其他窗口中的部件获取输入.此属性的值控制对应窗口可见时阻塞哪些类 ...
随机推荐
- vs2017_enterprise正式版离线安装包bt下载
vs2017_enterprise正式版离线安装包bt下载 点击这里下载种子 磁力链接 安装前请先打开certificates目录,安装里面的三个证书 离线下载教程 : https://docs.mi ...
- linux系统下安装ruby环境
1. 移除现有 Ruby 默认源 输入以下指令 $gem sources --remove https://rubygems.org/ 2. 使用新的源 输入以下指令 $gem sources -a ...
- Study 3 —— Python运算符
参考资料:http://www.runoob.com/python/python-operators.html#ysf2 定义变量: a = 10, b = 20 算术运算符: 运算符 描述 实例 ...
- C# 面向对象的base的使用
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- 有关ACM学习的博客链接
大综合: 杭电OJ水题大全题解:http://blog.csdn.net/ysc504?viewmode=contents 14级浙江财经大学大佬:http://blog.csdn.net/jtjy5 ...
- css命名规范: BEM 的命名法
整理自:前端早读课[第1183期]这些 CSS 命名规范,将省下你大把调试时间 试图解决 3 类问题: 仅从名字就能知道一个 CSS 选择器具体做什么 从名字能大致清楚一个选择器可以在哪里使用 从 C ...
- http raw post 之理解
参考链接: https://imququ.com/post/four-ways-to-post-data-in-http.html http://blog.csdn.net/leyangjun/art ...
- js sort方法根据数组中对象的某一个属性值进行排序
sort方法接收一个函数作为参数,这里嵌套一层函数用来接收对象属性名,其他部分代码与正常使用sort方法相同. var arr = [ {name:'zopp',age:0}, {name:'gpp' ...
- D3开发中的资料整理
D3开发台阶比较高,需要对html,css,js非常熟练,还要对SVG非常熟悉,SVG不会就不要开发D3了,下面给大家推荐一本资料,为大家未来的开发提供便利. 这个框架产品不支持ie8,是这个产品的特 ...
- linux中结构体对齐【转】
转自:https://blog.csdn.net/suifengpiao_2011/article/details/47260085 linux中定义对齐字节 typedef struct sdk_ ...