List of usage examples for javafx.fxml FXMLLoader load
public static <T> T load(URL location) throws IOException
From source file:cz.lbenda.gui.controls.TextAreaFrmController.java
/** Create new instance return main node and controller of this node and sub-nodes */ public static Tuple2<Parent, TextAreaFrmController> createNewInstance() { URL resource = TextAreaFrmController.class.getResource(FXML_RESOURCE); try {//from w ww .ja v a 2s .c om FXMLLoader loader = new FXMLLoader(); loader.setLocation(resource); loader.setBuilderFactory(new JavaFXBuilderFactory()); Parent node = loader.load(resource.openStream()); TextAreaFrmController controller = loader.getController(); return new Tuple2<>(node, controller); } catch (IOException e) { LOG.error("Problem with reading FXML", e); throw new RuntimeException("Problem with reading FXML", e); } }
From source file:cz.lbenda.dataman.db.frm.DbConfigFrmController.java
/** Create new instance return main node and controller of this node and sub-nodes */ public static Tuple2<Parent, DbConfigFrmController> createNewInstance() { URL resource = DbConfigFrmController.class.getResource(FXML_RESOURCE); try {/*from w w w.j av a 2 s.co m*/ FXMLLoader loader = new FXMLLoader(); loader.setLocation(resource); loader.setBuilderFactory(new JavaFXBuilderFactory()); Parent node = loader.load(resource.openStream()); DbConfigFrmController controller = loader.getController(); return new Tuple2<>(node, controller); } catch (IOException e) { LOG.error("Problem with reading FXML", e); throw new RuntimeException("Problem with reading FXML", e); } }
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();// w ww.j a v a 2s . c o m }
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);// w ww.j av a2 s .c om stage.setMinHeight(SCENE_MIN_HEIGHT); stage.setScene(scene); stage.show(); }
From source file:pl.mcpg.nbtjeditor.Start.java
@Override public void start(Stage stage) { Parent parent = null;/*from w w w. j a v a2s. 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:nl.rivm.cib.fx.HelloWorldJavaFX.java
@Override public void start(final Stage stage) throws Exception { LOG.info("Starting Hello JavaFX and Maven demonstration application"); String fxmlFile = "/fxml/hello.fxml"; LOG.debug("Loading FXML for main view from: {}", fxmlFile); FXMLLoader loader = new FXMLLoader(); Parent rootNode = (Parent) loader.load(getClass().getResourceAsStream(fxmlFile)); LOG.debug("Showing JFX scene"); Scene scene = new Scene(rootNode, 400, 200); scene.getStylesheets().add("/styles/styles.css"); stage.setTitle("Hello JavaFX and Maven"); stage.setScene(scene);//from w ww.j a v a 2s .c o m stage.show(); }
From source file:ninja.javafx.smartcsv.fx.FXMLController.java
protected final void loadFXML() throws IOException { try (InputStream fxmlStream = getClass().getResourceAsStream(fxmlFilePath)) { FXMLLoader loader = new FXMLLoader(); loader.setResources(ResourceBundle.getBundle(this.resourcePath)); loader.setController(this); this.view = (loader.load(fxmlStream)); } catch (Throwable t) { t.printStackTrace();//from w ww . ja v a 2 s . co m } }
From source file:at.ac.tuwien.qse.sepm.gui.App.java
@Override public void start(Stage stage) throws Exception { logger.info("Application started."); FXMLLoader loader = new FXMLLoader(); loader.setControllerFactory(context::getBean); // set base location so that resources can be loaded using relative paths loader.setLocation(getClass().getClassLoader().getResource("view")); Parent root = loader.load(getClass().getClassLoader().getResourceAsStream("view/Main.fxml")); stage.setScene(new Scene(root)); stage.setTitle("travelimg"); stage.getIcons().add(getApplicationIcon()); stage.show();/* w w w .ja v a2s . co m*/ PhotoService photoService = (PhotoService) context.getBean("photoService"); photoService.initializeRepository(); }
From source file:retsys.client.controller.LoginController.java
private Initializable replaceSceneContent(String fxml) throws Exception { URL location = getClass().getResource(fxml); FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()); InputStream in = getClass().getResourceAsStream(fxml); Parent root;// ww w .j ava2s . c o m fxmlLoader.setLocation(location); AnchorPane page; try { page = (AnchorPane) fxmlLoader.load(in); } finally { in.close(); } Scene scene = new Scene(page); scene.getStylesheets().add(this.getClass().getResource("/retsys/client/css/styles.css").toExternalForm()); stage.setScene(scene); stage.setFullScreen(true); //stage.sizeToScene(); return (Initializable) fxmlLoader.getController(); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void handleMenuSettingsPreferences(ActionEvent event) throws Exception { Stage preferencesStage = new Stage(); preferencesStage.initModality(Modality.WINDOW_MODAL); FXMLLoader fxmlLoader = new FXMLLoader(); Parent root = (Parent) fxmlLoader.load(getClass().getResource("preferences.fxml").openStream()); PreferencesController controller = fxmlLoader.getController(); controller.setPrimaryStage(preferencesStage); controller.setPrimaryController(this); preferencesStage.setTitle("Talismane Terminology Viewer Preferences"); preferencesStage.setScene(new Scene(root, 400, 300)); preferencesStage.show();// www . j a v a 2 s.c om }