List of usage examples for javafx.fxml FXMLLoader getController
@SuppressWarnings("unchecked") public <T> T getController()
From source file:org.craftercms.social.migration.MigrationTool.java
@Override public void start(final Stage primaryStage) throws Exception { loadProperties();/*from ww w. j a va 2 s .com*/ log.debug("Loading Fxml file"); FXMLLoader loader = new FXMLLoader(getClass().getResource("/scenes/Main.fxml")); log.debug("Fxml file Loaded, Starting scene"); Scene scene = new Scene((VBox) loader.load()); final MainController controller = loader.getController(); controller.setScene(scene); primaryStage.setScene(scene); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(final WindowEvent windowEvent) { controller.stopTasks(); } }); primaryStage.setTitle("Crafter Social/Profile Migration Tool (2.3->2.5)"); log.debug("Showing UI. {}", new Date()); primaryStage.show(); }
From source file:viewfx.view.support.fxml.FxmlViewLoader.java
public View loadFromFxml(URL fxmlUrl) { checkNotNull(fxmlUrl, "FXML URL must not be null"); try {//w w w . j a v a 2 s . c o m FXMLLoader loader = new FXMLLoader(fxmlUrl, resourceBundle); loader.setControllerFactory(viewFactory); loader.load(); Object controller = loader.getController(); if (controller == null) throw new ViewfxException("Failed to load view from FXML file at [%s]. " + "Does it declare an fx:controller attribute?", fxmlUrl); if (!(controller instanceof View)) throw new ViewfxException( "Controller of type [%s] loaded from FXML file at [%s] " + "does not implement [%s] as expected.", controller.getClass(), fxmlUrl, View.class); return (View) controller; } catch (IOException ex) { throw new ViewfxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl); } }
From source file:com.toyota.carservice.config.config2.java
public Object loadAnchorPane(AnchorPane ap, String a) { try {/* w w w .j ava2s .c om*/ FXMLLoader p = new FXMLLoader(getClass().getResource("/com/toyota/carservice/view/" + a)); ap.getChildren().setAll((AnchorPane) p.load()); return p.getController(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:br.com.ajaio.midas.desktop.MainApp.java
private void showLoginView() { try {//from w ww . j a va 2s. co m FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("view/loginFXML.fxml")); AnchorPane loginview = (AnchorPane) loader.load(); LoginController controller = loader.getController(); controller.setMainApp(this); rootLayout.setCenter(loginview); } catch (IOException e) { e.printStackTrace(); } }
From source file:br.com.ajaio.midas.desktop.MainApp.java
public void initRootLayout() { try {//from w ww. j a v a 2 s . com FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("view/rootLayoutFXML.fxml")); rootLayout = (BorderPane) loader.load(); RootLayoutController rootLayoutController = loader.getController(); rootLayoutController.setMainApp(this); Scene scene = new Scene(rootLayout); primaryStage.setScene(scene); primaryStage.show(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:br.com.ajaio.midas.desktop.MainApp.java
public void showBancoCrud() { try {/* w ww. j a v a2 s . c o m*/ FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("view/bancoCrudFXML.fxml")); AnchorPane bancoCrud = (AnchorPane) loader.load(); BancoCrudFXMLController bancoController = loader.getController(); bancoController.setMainApp(this); rootLayout.setCenter(bancoCrud); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.com.ajaio.midas.desktop.MainApp.java
public void showDashBoardView() { try {//from w ww.jav a 2 s. c o m FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("view/dashBoardFXML.fxml")); AnchorPane dashBoardOverview = (AnchorPane) loader.load(); DashBoardController controller = loader.getController(); controller.setMainApp(this); controller.setUsuarioLogado(usuarioLogado); controller.loadDashBoard(); rootLayout.setCenter(dashBoardOverview); } catch (Exception e) { e.printStackTrace(); } }
From source file:tworpus.client.mainwindow.MainWindowController.java
@FXML public void showCorpusForm() { try {/* w w w . j ava 2s .c om*/ FXMLLoader loader = new FXMLLoader(createCorpusFXML); Pane pane = (Pane) loader.load(); // @TODO: may be deleted. Just for demonstation how to get controller CreateCorpusController controller = loader.getController(); maincontent = pane; borderPane.centerProperty().set(maincontent); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.esri.geoevent.clusterSimulator.ui.CertificateCheckerDialog.java
@Override public boolean allowConnection(final X509Certificate[] chain) { if (trustedCerts.contains(chain[0])) { return true; }/* w w w .j a v a 2 s . co m*/ final ArrayBlockingQueue<Boolean> responseQueue = new ArrayBlockingQueue<Boolean>(1); Runnable runnable = new Runnable() { @Override public void run() { try { final Stage dialog = new Stage(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(MainApplication.primaryStage); dialog.setTitle("Certificate Check"); FXMLLoader loader = new FXMLLoader(getClass().getResource("CertificateCheckerDialog.fxml")); Parent parent = (Parent) loader.load(); CertCheckController controller = (CertCheckController) loader.getController(); controller.certText.setText(chain[0].toString()); Scene scene = new Scene(parent); dialog.setScene(scene); dialog.showAndWait(); responseQueue.put(Boolean.valueOf(controller.allowConnection)); } catch (Exception e) { e.printStackTrace(); } } }; if (Platform.isFxApplicationThread()) { runnable.run(); } else { Platform.runLater(runnable); } try { boolean retVal = responseQueue.take(); if (retVal) { trustedCerts.add(chain[0]); } return retVal; } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:dbsdemo.RegistrationWindowController.java
public void goToMainWindowScene(User user) { // Load properties file - TODO catch exception Properties prop = PropLoader.load("etc/config.properties"); // Continue to main window screen try {/*from www. j av a2s. c o m*/ FXMLLoader loader = new FXMLLoader(getClass().getResource(prop.getProperty("MainWindowPath"))); Parent root = (Parent) loader.load(); MainWindowController mainWindowController = loader.getController(); mainWindowController.setActiveUser(user); //Scene scene = new Scene(root); Stage mainWindowStage = new Stage(); mainWindowStage.setTitle("Fuel database"); mainWindowStage.setMinHeight(mainWindowStage.getHeight()); mainWindowStage.setMinWidth(mainWindowStage.getWidth()); mainWindowStage.setScene(new Scene(root)); mainWindowStage.show(); } catch (IOException ex) { Logger.getLogger(LoginWindowController.class.getName()).log(Level.SEVERE, null, ex); } }