- 浏览: 2146120 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (1240)
- mac/IOS (287)
- flutter (1)
- J2EE (115)
- android基础知识 (582)
- android中级知识 (55)
- android组件(Widget)开发 (18)
- android 错误 (21)
- javascript (18)
- linux (70)
- 树莓派 (18)
- gwt/gxt (1)
- 工具(IDE)/包(jar) (18)
- web前端 (17)
- java 算法 (8)
- 其它 (5)
- chrome (7)
- 数据库 (8)
- 经济/金融 (0)
- english (2)
- HTML5 (7)
- 网络安全 (14)
- 设计欣赏/设计窗 (8)
- 汇编/C (8)
- 工具类 (4)
- 游戏 (5)
- 开发频道 (5)
- Android OpenGL (1)
- 科学 (4)
- 运维 (0)
- 好东西 (6)
- 美食 (1)
最新评论
-
liangzai_cool:
请教一下,文中,shell、C、Python三种方式控制led ...
树莓派 - MAX7219 -
jiazimo:
...
Kafka源码分析-序列5 -Producer -RecordAccumulator队列分析 -
hp321:
Windows该命令是不是需要安装什么软件才可以?我试过不行( ...
ImageIO读jpg的时候出现javax.imageio.IIOException: Unsupported Image Type -
hp321:
Chenzh_758 写道其实直接用一下代码就可以解决了:JP ...
ImageIO读jpg的时候出现javax.imageio.IIOException: Unsupported Image Type -
huanghonhpeng:
大哥你真强什么都会,研究研究。。。。小弟在这里学到了很多知识。 ...
android 浏览器
1. 标准对话框
消息对话框
没有标题的消息对话框
2. 警告对话框
3. 错误对话框
4. 异常对话框
这不是一个完整的异常对话框。但我们可以很容易地将 TextArea 作为可扩展的内容。
5. 确认对话框
6. 自定义确认对话框
7. 可输入的对话框
8. 可选择的对话框
9. 自定义登录框
10. 修改对话框样式
自定义图标
说明:根据JavaFX 8u40最终版本的BUG报告,应该使用与它正在运行的应用程序相同的图标。在这种情况下,你还需要设置它的所有者,对话框会得到所有者的图标:
不使用图标
11. 其他操作
设置拥有者
你可以为每一个对话框指定所有者。如果指定所有者或拥有者为null,那么它是一个顶级的、未拥有的对话框。
设置模式
你可以指定对话框的模式,包括Modality.NONE、WINDOW_MODAL或Modality.APPLICATION_MODAL。
消息对话框
Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information Dialog"); alert.setHeaderText("Look, an Information Dialog"); alert.setContentText("I have a great message for you!"); alert.showAndWait();
没有标题的消息对话框
Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information Dialog"); alert.setHeaderText(null); alert.setContentText("I have a great message for you!"); alert.showAndWait();
2. 警告对话框
Alert alert = new Alert(AlertType.WARNING); alert.setTitle("Warning Dialog"); alert.setHeaderText("Look, a Warning Dialog"); alert.setContentText("Careful with the next step!"); alert.showAndWait();
3. 错误对话框
Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Look, an Error Dialog"); alert.setContentText("Ooops, there was an error!"); alert.showAndWait();
4. 异常对话框
这不是一个完整的异常对话框。但我们可以很容易地将 TextArea 作为可扩展的内容。
Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Exception Dialog"); alert.setHeaderText("Look, an Exception Dialog"); alert.setContentText("Could not find file blabla.txt!"); Exception ex = new FileNotFoundException("Could not find file blabla.txt"); // Create expandable Exception. StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); String exceptionText = sw.toString(); Label label = new Label("The exception stacktrace was:"); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); // Set expandable Exception into the dialog pane. alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait();
5. 确认对话框
Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Look, a Confirmation Dialog"); alert.setContentText("Are you ok with this?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ // ... user chose OK } else { // ... user chose CANCEL or closed the dialog }
6. 自定义确认对话框
Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog with Custom Actions"); alert.setHeaderText("Look, a Confirmation Dialog with Custom Actions"); alert.setContentText("Choose your option."); ButtonType buttonTypeOne = new ButtonType("One"); ButtonType buttonTypeTwo = new ButtonType("Two"); ButtonType buttonTypeThree = new ButtonType("Three"); ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo, buttonTypeThree, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeOne){ // ... user chose "One" } else if (result.get() == buttonTypeTwo) { // ... user chose "Two" } else if (result.get() == buttonTypeThree) { // ... user chose "Three" } else { // ... user chose CANCEL or closed the dialog }
7. 可输入的对话框
TextInputDialog dialog = new TextInputDialog("walter"); dialog.setTitle("Text Input Dialog"); dialog.setHeaderText("Look, a Text Input Dialog"); dialog.setContentText("Please enter your name:"); // Traditional way to get the response value. Optional<String> result = dialog.showAndWait(); if (result.isPresent()){ System.out.println("Your name: " + result.get()); } // The Java 8 way to get the response value (with lambda expression). result.ifPresent(name -> System.out.println("Your name: " + name));
说明:如果用户点击了取消按钮result.isPresent()将会返回false
8. 可选择的对话框
List<String> choices = new ArrayList<>(); choices.add("a"); choices.add("b"); choices.add("c"); ChoiceDialog<String> dialog = new ChoiceDialog<>("b", choices); dialog.setTitle("Choice Dialog"); dialog.setHeaderText("Look, a Choice Dialog"); dialog.setContentText("Choose your letter:"); // Traditional way to get the response value. Optional<String> result = dialog.showAndWait(); if (result.isPresent()){ System.out.println("Your choice: " + result.get()); } // The Java 8 way to get the response value (with lambda expression). result.ifPresent(letter -> System.out.println("Your choice: " + letter));
引用
说明:如果用户没有选择或点击了取消,result.isPresent()将会返回false
9. 自定义登录框
// Create the custom dialog. Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Login Dialog"); dialog.setHeaderText("Look, a Custom Login Dialog"); // Set the icon (must be included in the project). dialog.setGraphic(new ImageView(this.getClass().getResource("login.png").toString())); // Set the button types. ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField username = new TextField(); username.setPromptText("Username"); PasswordField password = new PasswordField(); password.setPromptText("Password"); grid.add(new Label("Username:"), 0, 0); grid.add(username, 1, 0); grid.add(new Label("Password:"), 0, 1); grid.add(password, 1, 1); // Enable/Disable login button depending on whether a username was entered. Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). username.textProperty().addListener((observable, oldValue, newValue) -> { loginButton.setDisable(newValue.trim().isEmpty()); }); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> username.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { return new Pair<>(username.getText(), password.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(usernamePassword -> { System.out.println("Username=" + usernamePassword.getKey() + ", Password=" + usernamePassword.getValue()); });
10. 修改对话框样式
自定义图标
// Get the Stage. Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); // Add a custom icon. stage.getIcons().add(new Image(this.getClass().getResource("login.png").toString()));
说明:根据JavaFX 8u40最终版本的BUG报告,应该使用与它正在运行的应用程序相同的图标。在这种情况下,你还需要设置它的所有者,对话框会得到所有者的图标:
dialog.initOwner(otherStage);
不使用图标
dialog.initStyle(StageStyle.UTILITY);
11. 其他操作
设置拥有者
你可以为每一个对话框指定所有者。如果指定所有者或拥有者为null,那么它是一个顶级的、未拥有的对话框。
dialog.initOwner(parentWindow);
设置模式
你可以指定对话框的模式,包括Modality.NONE、WINDOW_MODAL或Modality.APPLICATION_MODAL。
dialog.initModality(Modality.NONE);
发表评论
-
小程序textarea完美填坑
2020-07-07 16:09 461相信做微信小程序的码友们都被textarea这个原生组件坑过 ... -
Nginx+Https自己敲命令生成证书
2020-05-18 09:35 899一、准备 环境:centos6.8 ... -
https证书生成环境搭建配置(基于Tomcat和Nginx)
2020-04-24 11:06 781一、基于Tomcat、JDK内置密钥工具: 1、生成服务端证 ... -
史上最强Tomcat8性能优化
2019-11-01 21:41 731授人以鱼不如授人以渔 ... -
SpringBoot配置HTTPS,并实现HTTP访问自动转HTTPS访问
2019-10-07 09:13 5191.使用jdk自带的 keytools 创建证书 打开cmd ... -
Spring Boot工程集成全局唯一ID生成器 UidGenerator
2019-09-16 09:04 809概述 流水号生成器(全局唯一 ID生成器)是服务化系统的基础 ... -
CentOS7下Redis的安装与使用
2019-08-17 11:45 556一、手动安装过程 1、准备工作(安装gcc依赖) yum ... -
Nginx与tomcat组合的简单使用
2019-08-17 10:05 367配置tomcat跳转 请求http出现400的时候在这里配置 ... -
linux下lvs+keepalived安装配置
2019-07-10 14:20 432keepalived主机:192.168.174. ... -
使用Docker搭建Tomcat运行环境
2019-02-08 21:32 4461 准备宿主系统 准备一 ... -
Netty笔记-GlobalEventExecutor
2019-02-06 23:00 5791.概念 /** * Single-thread si ... -
Netty4转发服务的实现方案
2019-02-06 15:03 1040如果用Netty做转发服务(不需要同步应答),Netty中有一 ... -
java手机号归属地查询
2018-12-25 17:16 703所需的包:carrier-1.75.jar 、geocoder ... -
基于Netty4的HttpServer和HttpClient的简单实现
2018-10-17 20:02 626Http 消息格式: Http request: Met ... -
javafx : 支持使用微调(spinner)控制的数字的文本框(NemberTextField)
2018-10-16 00:00 994最近花了一些时间学习javaFX, 要更深入地理解新GUI包, ... -
我的Java(定制你的Java/JavaFX Runtime)
2018-10-12 23:29 631最新的JDK 11发布了,撒花 新版本的JDK终于有了ope ... -
javaFX的几个新特性,让swing彻底过时
2018-10-12 22:42 607首先声明,Java的GUI曾经 ... -
mac os系统用install4j把jar包生成app
2018-10-05 23:02 1353install4j有windows版也有mac版 mac电脑 ... -
IDEA Properties中文unicode转码问题
2017-02-17 19:54 929摘要: 如何让IDEA的properties中的中文进行uni ... -
spring 3中新增的@value注解
2016-11-01 09:32 599在spring 3.0中,可以通过使用@value,对一些如x ...
相关推荐
Alert消息框中设置icon图标的例子
简单的 JavaFX 对话框
JavaFX API文档。Sun公司已于2008年12月05日发布了JavaFX技术的正式版,它使您能利用 JavaFX 编程语言开发互联网应用程序(RIA)。该产品于2007年5月在JavaOne大会上首次对外公布。JavaFX技术主要应用于创建Rich ...
javafx
JavaFx做界面VLC做视频处理,请看源码
JavaFX教程;JavaFX教程;JavaFX教程JavaFX教程;
javaFX Demo 模板案例
linux系统下,可用如下两命令运 行 javafx 的 jar包 export JAVAFX=/home/这里是linux的用户名文件夹/javafx-sdk-18/lib java --module-path $JAVAFX --add-modules javafx.fxml,javafx.controls -jar demo.jar 或都...
javaFX高级教程JavaFX2.0的FXML语言 中文文档,想免费上传,CSDN不同意,选了一个最小资源分2
Sun公司已于2008年12月05日发布了JavaFX技术的正式版,它使您能利用 JavaFX 编程语言开发互联网应用程序(RIA)。该产品于2007年5月在JavaOne大会上首次对外公布。JavaFX技术主要应用于创建Rich Internet ...
JavaFX api文档 chm格式
Java11以后的版本不再集成Javafx,需要单独下载
javafx2.0,java,javafx,例子,代码 Sun公司(已于20092008年12月05日发布了JavaFX技术的正式版,它使您能利用 JavaFX 编程语 言开发富互联网应用程序(RIA)。JavaFX Script编程语言(以下称为JavaFX)是Sun微...
javafx8api文档
闲来无事,写了个Springboot JavaFx mysql mybatis整合模板,方便以后windows桌面程序迅速开发,直接套用即可! 要用的话,application配置文件自己改一下数据库账号密码,以及mapper和.fxml的Controller路径!
用JavaFx开发的模仿Windows的画图板工具
javaFX登陆和跳转
javaFX单独放大缩小图片和移动图片的很多,很难找到能缩放和移动一起实现的例子。由于项目的需要就自己写了个javaFX实现图片放大(以图片中心放大)、缩小、鼠标移动。(netbeans项目)
JavaFX Script编程语言是Sun微系统公司开发的一种declarative,statically typed(声明性的、静态类型)脚本语言。JavaFX技术有着良好的前景,包括可以直接调用Java API的能力。
资源名称:JavaFX 8 技术手册资源截图: 资源太大,传百度网盘了,链接在附件中,有需要的同学自取。