List of usage examples for javafx.fxml FXMLLoader FXMLLoader
public FXMLLoader()
From source file:org.sandsoft.cymric.util.Commons.java
/** * Create a new custom pane from FXML data. <br> * Restraints: Name and package of FXML file should be the same as * <code>resourceClass</code>. <code>resourceClass</code> should extend * <code>BorderPane</code> or one of its descendents. * * @param resourceClass Pane class in which data to be loaded. * @return Pane type object containing loaded node. *//*from ww w . ja va 2 s . c o m*/ public static Pane loadPaneFromFXML(Class resourceClass) throws IOException { //init loader FXMLLoader loader = new FXMLLoader(); loader.setLocation(resourceClass.getResource(resourceClass.getSimpleName() + ".fxml")); //load fxml Node node = (Node) loader.load(); BorderPane control = (BorderPane) loader.getController(); BorderPane.setAlignment(node, Pos.CENTER); control.setCenter(node); return control; }
From source file:Main.java
@Override public void start(final Stage stage) throws Exception { FXMLLoader f = new FXMLLoader(); final Parent fxmlRoot = (Parent) f.load(new FileInputStream(new File("JavaFx2Menus.fxml"))); stage.setScene(new Scene(fxmlRoot)); stage.show();// ww w. ja v a 2 s . c om }
From source file:com.fxexperience.previewer.controller.PreviewController.java
public PreviewController() { try {//from ww w. j av a2s. co m final FXMLLoader loader = new FXMLLoader(); loader.setLocation(PreviewController.class.getResource("/fxml/FXMLPreviewPanel.fxml")); //NOI18N loader.setController(PreviewController.this); loader.setRoot(PreviewController.this); loader.load(); } catch (IOException ex) { Logger.getLogger(PreviewController.class.getName()).log(Level.SEVERE, null, ex); } choiceBox.getSelectionModel().select(0); comboBox.getSelectionModel().select(0); listView.setItems(FXCollections.observableArrayList("Alpha", "Beta", "Gamma")); // System.out.println(this.getUserAgentStylesheet()); }
From source file:com.coolchick.translatortemplater.Main.java
/** * Shows the person overview inside the root layout. *///w ww. j ava2 s .c om public void showTranslatorOverview() { try { // Load person overview. FXMLLoader loader = new FXMLLoader(); loader.setLocation(Main.class.getResource("PersonOverview.fxml")); StackPane personOverview = loader.load(); PersonOverviewController controller = loader.getController(); controller.setMain(this); controller.setTranslators(getTranslators()); primaryStage.setScene(new Scene(personOverview, 800, 600)); } catch (IOException e) { e.printStackTrace(); } }
From source file:br.com.ajaio.midas.desktop.MainApp.java
public void initRootLayout() { try {//from w w w. j ava2 s .co m 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:pl.mcpg.nbtjeditor.Start.java
@Override public void start(Stage stage) { Parent parent = null;//from w ww . jav a 2 s . c o m FXMLLoader loader = new FXMLLoader(); try { parent = loader.load(getClass().getResourceAsStream("/main.fxml")); } catch (Exception e) { displayError("Couldn't load main FXML file! Application will\nnow close.", e); e.printStackTrace(); System.exit(1); } stage.setMinWidth(150); stage.setMinHeight(150); stage.setTitle(APP_TITLE); stage.setScene(new Scene(parent, 640, 480)); ((MainController) loader.getController()).setStage(stage); stage.show(); if (fileToOpen != null && fileToOpen.exists()) { ((MainController) loader.getController()).open(null); } }
From source file:com.ro.ssc.app.client.licensing.TrialKeyGenerator.java
@Override public void start(Stage stage) throws Exception { log.info("Starting Litho InSight"); this.stage = stage; log.debug("Loading FXML for main view from: {}", ROOT_LAYOUT_FILE); FXMLLoader loader = new FXMLLoader(); Parent rootNode = (Parent) loader.load(getClass().getResourceAsStream(ROOT_LAYOUT_FILE)); log.debug("Showing JFX scene"); Scene scene = new Scene(rootNode, SCENE_MIN_WIDTH, SCENE_MIN_HEIGHT); // scene.getStylesheets().add(MAIN_CSS_FILE); stage.setTitle("Soft Pontaj v2.0"); stage.setMinWidth(SCENE_MIN_WIDTH);//from w w w. j a va2 s. c o m stage.setMinHeight(SCENE_MIN_HEIGHT); stage.setScene(scene); stage.show(); }
From source file:org.pieShare.pieShareAppFx.springConfiguration.PieShareAppFx.java
@Bean @Lazy/* w w w .j a va 2 s . co m*/ @Scope(value = "prototype") public FXMLLoader fxmlLoader() { FXMLLoader loader = new FXMLLoader(); loader.setControllerFactory(controllerFactory()); return loader; }
From source file:fx.browser.Window.java
public void setLocation(String location) throws URISyntaxException { System.out.println("# " + this.toString() + "-Classloader: " + getClass().getClassLoader().toString() + " setLocation()"); this.location = location; HttpGet httpGet = new HttpGet(new URI(location)); try (CloseableHttpResponse response = Browser.getHttpClient().execute(httpGet)) { switch (response.getStatusLine().getStatusCode()) { case HttpStatus.SC_OK: FXMLLoader loader = new FXMLLoader(); Header header = response.getFirstHeader("class-loader-url"); if (header != null) { URL url = new URL(location); url = new URL(url.getProtocol(), url.getHost(), url.getPort(), header.getValue()); if (logger.isLoggable(Level.INFO)) { logger.log(Level.INFO, "Set up remote classloader: {0}", url); }//from w ww . j a va2 s . c om loader.setClassLoader(HttpClassLoader.getInstance(url, getClass().getClassLoader())); } try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); response.getEntity().writeTo(buffer); response.close(); setContent(loader.load(new ByteArrayInputStream(buffer.toByteArray()))); } catch (Exception e) { response.close(); logger.log(Level.INFO, e.toString(), e); Node node = loader.load(getClass().getResourceAsStream("/fxml/webview.fxml")); WebViewController controller = (WebViewController) loader.getController(); controller.view(location); setContent(node); } break; case HttpStatus.SC_UNAUTHORIZED: response.close(); Optional<Pair<String, String>> result = new LoginDialog().showAndWait(); if (result.isPresent()) { URL url = new URL(location); Browser.getCredentialsProvider().setCredentials(new AuthScope(url.getHost(), url.getPort()), new UsernamePasswordCredentials(result.get().getKey(), result.get().getValue())); setLocation(location); } break; } } catch (IOException e) { e.printStackTrace(); } }
From source file:main.Content.java
public void initRootLayout() { try {/*w w w .j a v a 2s . c o m*/ FXMLLoader loader = new FXMLLoader(); loader.setLocation(Content.class.getResource("view/ContentRoot.fxml")); rootLayout = (BorderPane) loader.load(); ContentRootController controller = loader.getController(); controller.setMainApp(this); } catch (IOException e) { e.printStackTrace(); } }