List of usage examples for javafx.fxml FXMLLoader load
public <T> T load() throws IOException
From source file:viewfx.view.support.fxml.FxmlViewLoader.java
public View loadFromFxml(URL fxmlUrl) { checkNotNull(fxmlUrl, "FXML URL must not be null"); try {/*from w w w . ja v a2s .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:org.apache.cayenne.modeler.layout.LayoutSupport.java
default FXMLLoader loadFXML(final String fxmlPath) throws IOException { final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(fxmlPath)); fxmlLoader.setRoot(this); fxmlLoader.setController(this); fxmlLoader.load(); // Note: Must manually initialize the layout because JavaFX will not // automatically call the "initialize" method when the FXML is // loaded from an interface's default method. To avoid confusion // with the JavaFX "initialize" name, a different method name is // used for the same purpose. initializeLayout();//from ww w.j a v a2s.c om return fxmlLoader; }
From source file:br.com.ajaio.midas.desktop.MainApp.java
private void showLoginView() { try {// www . jav a 2 s.c om 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 showBancoCrud() { try {//from w ww .j a va 2 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 w w.ja v a2 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:dtv.DTVEdit.java
private Object load(String url) { FXMLLoader loader = new FXMLLoader(); loader.setControllerFactory(clazz -> applicationContext.getBean(clazz)); loader.setLocation(DTVEdit.class.getResource(url)); try {/* w ww . j a v a 2 s .c o m*/ return loader.load(); } catch (IOException e) { LOG.error("Some bad things!", e); } return null; }
From source file:ninja.eivind.hotsreplayuploader.window.nodes.BattleLobbyNode.java
public BattleLobbyNode(FXMLLoaderFactory factory) throws IOException { URL resource = getClass().getResource("BattleLobbyNode.fxml"); FXMLLoader loader = factory.get(); loader.setLocation(resource);//from ww w . ja v a 2 s . com loader.setRoot(this); loader.setController(this); loader.load(); }
From source file:com.toyota.carservice.config.config2.java
public Object loadAnchorPane(AnchorPane ap, String a) { try {/* w ww .j a v a2s. 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:spdxedit.license.LicenseExtractControl.java
public Pane getUi() { try {//from ww w . j a va2 s . c o m FXMLLoader loader = new FXMLLoader( LicenseExtractControl.class.getResource("/ExtractLicenseDialog.fxml")); loader.setController(this); Pane pane = loader.load(); return pane; } catch (IOException ioe) { throw new RuntimeException("Unable to load scene for License editor dialog"); } }
From source file:com.esri.geoevent.clusterSimulator.ui.CertificateCheckerDialog.java
@Override public boolean allowConnection(final X509Certificate[] chain) { if (trustedCerts.contains(chain[0])) { return true; }//from ww w . ja va 2 s . c o 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; }