當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。