javafx fxml 最简示例
2017-01-02 22:11
411 查看
@Override
public void start(Stage primaryStage) {
try {
//1,创建FXMLLoader
//2,加载fxml文件,
//3,取得pane
//4,创建scene
//5,设置stage
//6,调用show方法
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("login.fxml"));
AnchorPane pane = (AnchorPane) loader.load();
Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void start(Stage primaryStage) {
try {
//1,创建FXMLLoader
//2,加载fxml文件,
//3,取得pane
//4,创建scene
//5,设置stage
//6,调用show方法
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("login.fxml"));
AnchorPane pane = (AnchorPane) loader.load();
Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
相关文章推荐
- java的IO流详解(一)
- Android Studio与eclipse的选择
- 理解Spring AOP 原理(三)Spring AOP 源码分析
- java学习方向及主要内容
- Spring和SpringMVC的区别
- springmvc处理上传图片代码(校验图片尺寸、图片大小)
- 【Java编程高级进阶】java 获取 string 字符串的编码详解
- Java知识点练习小结(二)
- MyEclipse10--的使用经验
- 步步扎进java-集合之Map
- 自定义功能模块设计
- SpringMVC与Struts2区别与比较总结
- 【JAVA 10.26】
- SpringCloud+Consul 服务注册与服务发现
- SpringMVC学习总结(四).SpringMVC处理Json与文件的上传下载
- struts2中采用拦截器防止表单重复提交
- Java中的super和this
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式)
- Java同样的汉字在服务器和本地的电脑上URLencode 出来的结果不一致
- spring boot getWriter() has already been called for this response解决