当前位置: 首页>>代码示例>>Java>>正文


Java FXMLLoader.getRoot方法代码示例

本文整理汇总了Java中javafx.fxml.FXMLLoader.getRoot方法的典型用法代码示例。如果您正苦于以下问题:Java FXMLLoader.getRoot方法的具体用法?Java FXMLLoader.getRoot怎么用?Java FXMLLoader.getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.fxml.FXMLLoader的用法示例。


在下文中一共展示了FXMLLoader.getRoot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
    instance = this;
    applicationWindow = stage;
    Locale locale = Locale.US;
    ApplicationState.getInstance().setResourceBundle(ResourceBundle.getBundle("Bundle", locale));
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/App.fxml"));
    loader.setResources(ApplicationState.getInstance().getResourceBundle());
    loader.load();
    Parent root = loader.getRoot();
    appController = loader.getController();

    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/Styles.css");

    stage.setTitle("AEM External Package Inspect and Compare Tool");
    stage.setScene(scene);
    stage.show();
    applicationWindow.setOnCloseRequest(evt -> {
        Platform.exit();
        System.exit(0);
    });
}
 
开发者ID:Adobe-Consulting-Services,项目名称:aem-epic-tool,代码行数:24,代码来源:EpicApp.java

示例2: get

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
 * Create the view and controller associated with the provided FXML URL
 * 
 * @param url
 *            the location of the FXML file, relative to the
 *            {@code sic.nmsu.javafx} package
 * @param stateInit
 *            a consumer used to configure the controller before FXML injection
 * @return the initialized view and controller
 */
public static <C extends FXController> Pair<Parent, C> get(String url, Consumer<C> stateInit) {
	FXMLLoader loader = new FXMLLoader(App.class.getResource(url));
	loader.setControllerFactory(ctrlClass -> {
		@SuppressWarnings("unchecked")
		C ctrl = (C) Resolver.resolve(ctrlClass);
		if (stateInit != null)
			stateInit.accept(ctrl);
		return ctrl;
	});

	try {
		loader.load();
	} catch (IOException e) {
		logger.error(e.getMessage());
		e.printStackTrace();
		return null;
	}

	return new Pair<Parent, C>(loader.getRoot(), loader.getController());
}
 
开发者ID:NMSU-SIC-Club,项目名称:JavaFX_Tutorial,代码行数:31,代码来源:FXController.java

示例3: start

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
	Thread.currentThread().setUncaughtExceptionHandler(this::showJavaFxException);
	registerPropertyValueEditors();
	
	updater = new Updater();
	updater.setUpdatableRegister(UpdatableRegister.getInstance());
	Thread updateThread = new Thread(updater, "Update Thread");
	updateThread.setDaemon(true);
	updateThread.start();

	layerRenderer = new DefaultRenderer();
	Thread renderThread = new Thread(layerRenderer, "Render Thread");
	renderThread.setDaemon(true);
	renderThread.start();

	ResourceBundle resources = ResourceBundle.getBundle("fxml/i18n/klc");
	URL location = this.getClass().getResource("/fxml/KlcApplication.fxml");
	FXMLLoader loader = new FXMLLoader(location, resources);
	loader.load();

	KlcApplication controller = loader.getController();
	controller.setUpdater(updater);
	controller.setRenderer(layerRenderer);
	Scene scene = new Scene(loader.getRoot());

	// Start Server
       ExternalServer.startExternalServer();

	scene.getStylesheets().add("fxml/css/style.css");
	primaryStage.setScene(scene);
	primaryStage.setTitle("Keyboard Light Composer");
	primaryStage.show();
}
 
开发者ID:enoy19,项目名称:keyboard-light-composer,代码行数:35,代码来源:KeyboardLightComposerApplication.java

示例4: loadView

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@SneakyThrows
private View loadView() {
    InputStream fxmlStream = null;
    try {
        fxmlStream = getClass().getClassLoader().getResourceAsStream("app.fxml");
        FXMLLoader loader = new FXMLLoader();
        loader.load(fxmlStream);
        return new View(loader.getRoot(), loader.getController());
    } finally {
        if (fxmlStream != null) {
            fxmlStream.close();
        }
    }
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:15,代码来源:CassandraClientUIConfiguration.java


注:本文中的javafx.fxml.FXMLLoader.getRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。