package sample.fxml;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.stage.DirectoryChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class FXMLMain extends Application {
private URL location;
private Stage stage;
public Stage getStage(){
return stage;
}
public Pane loadFXML(InputStream in) {
FXMLLoader loader = new FXMLLoader();
loader.setBuilderFactory(new JavaFXBuilderFactory());
loader.setLocation(location);
try {
Pane pane = (Pane)loader.load(in);
Page page = (Page)loader.getController();
page.setMain(this);
return pane;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
public void popupWindow(Pane root, Stage stage) {
showStage(root, stage, this.stage);
}
private void showStage(Pane root, Stage stage, Stage parent) {
Scene scene = new Scene(root);
stage.setScene(scene);
stage.sizeToScene();
stage.setResizable(false);
if (parent != null) {
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(parent);
}
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
@Override
public void start(Stage stage) throws Exception {
String fxml = "FxmlSelection.fxml";
location = FXMLMain.class.getResource(fxml);
Pane pane = loadFXML(FXMLMain.class.getResourceAsStream(fxml));
if (pane == null)
return;
showStage(pane, stage, null);
this.stage = stage;
}
public static void main(String[] args) {
Application.launch(FXMLMain.class, (java.lang.String[])null);
}
}
加载任意位置的fxml文件
5星 · 超过95%的资源 需积分: 43 166 浏览量
2013-12-02
10:04:27
上传
评论
收藏 5KB ZIP 举报
lngrvr
- 粉丝: 7
- 资源: 3
最新资源
- DSP开发实战教程-国产DSP替代进口TI DSP的使用技巧 进芯DSP替换文件
- 植被恢复能力估算python代码(KNDVI代码).zip
- 基于java打造的深度学习框架,帮助你快速搭建神经网络,实现模型推理与训练,引擎支持自动求导,多线程与GPU运算
- 界线与不动产测绘智能计算经纬度及标注软件
- CANOPEN使用方法与教程
- 极影毁片圆 · 电脑字体设置.zip
- 同态加密部分算法实现Homomorphic-Encryption-main.zip
- helib同态加密socket通信helibsocket-master.zip
- pll_inst.vhd
- 快速入门同态加密homomorphic-encryption-master.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈