本文整理汇总了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);
});
}
示例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());
}
示例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();
}
示例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();
}
}
}