List of usage examples for javafx.fxml FXMLLoader FXMLLoader
public FXMLLoader(Charset charset)
From source file:com.rvantwisk.cnctools.controls.ToolParametersControl.java
public ToolParametersControl() { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ToolParameters.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try {//from w ww.j a v a2 s.c om fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } }
From source file:de.serverfrog.pw.ui.MainViewController.java
@FXML public void onLoadButton(ActionEvent ae) { try {/*from w w w . ja v a 2 s . com*/ if (this.masterPasswordField.getText().isEmpty()) { return; } Stage dialog = new Stage(StageStyle.UTILITY); dialog.initModality(Modality.APPLICATION_MODAL); FXMLLoader fXMLLoader = new FXMLLoader( getClass().getResource("/de/serverfrog/pw/ui/ConfigLoadDialog.fxml")); Parent root = fXMLLoader.<Parent>load(); ConfigLoadDialogController controller = fXMLLoader.<ConfigLoadDialogController>getController(); try { controller.prepareList(masterPasswordField.getText()); } catch (IOException exception) { this.messageField.setText(exception.getMessage()); return; } this.messageField.setText(""); Scene scene = new Scene(root); dialog.setScene(scene); controller.setStage(dialog); dialog.showAndWait(); setConfiguration(controller.getConfig()); } catch (IOException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:application.Main.java
@Override public void start(Stage primaryStage) throws InterruptedException { System.out.println(applicationTitle + " initialized!"); // define working variables String text = ""; Boolean terminateExecution = Boolean.FALSE; // does the specified FXML XML file path exist? String fxmlXmlFileFullPath = fxmlPath.equals("") ? fxmlXmlFileName : fxmlPath + "/" + fxmlXmlFileName; URL urlXml = Main.class.getResource(fxmlXmlFileFullPath); if (urlXml == null) { terminateExecution = Boolean.TRUE; text = Main.class.getName() + ": FXML XML File '" + fxmlXmlFileFullPath + "' not found in resource path!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); }/*from w ww.j a va 2 s . co m*/ // does the specified FXML CSS file path exist? String fxmlCssFileFullPath = fxmlPath.equals("") ? fxmlCssFileName : fxmlPath + "/" + fxmlCssFileName; URL urlCss = Main.class.getResource(fxmlCssFileFullPath); if (urlCss == null) { terminateExecution = Boolean.TRUE; text = Main.class.getName() + ": FXML CSS File '" + fxmlCssFileFullPath + "' not found in resource path!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); } if (terminateExecution) { text = Main.class.getName() + ": Execution terminated due to errors!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); GenericUtilities.outputToSystemOut(text, systemOutputDesired); return; } // initialize and display the primary stage try { // load the FXML file and instantiate the "root" object FXMLLoader fxmlLoader = new FXMLLoader(urlXml); Parent root = (Parent) fxmlLoader.load(); controller = (FracKhemGUIController) fxmlLoader.getController(); controller.setStage(primaryStage); controller.setInitStageTitle(applicationTitle); // initialize and display the stage createTrayIcon(primaryStage); firstTime = Boolean.TRUE; Platform.setImplicitExit(Boolean.FALSE); Scene scene = new Scene(root); scene.getStylesheets().add(urlCss.toExternalForm()); primaryStage.setScene(scene); primaryStage.setTitle(applicationTitle + " - " + controller.getPropFileCurrFileVal()); primaryStage.show(); } catch (Exception e) { text = ExceptionUtils.getStackTrace(e); GenericUtilities.outputToSystemErr(text, systemErrorsDesired); text = Main.class.getName() + ": Execution terminated due to errors!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); GenericUtilities.outputToSystemOut(text, systemOutputDesired); } }
From source file:com.exalttech.trex.ui.views.importPcap.ImportedPacketTableView.java
/** * Initialize view//w w w . j a v a 2 s. co m */ private void initView() { try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/ImportedPacketTableView.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); fxmlLoader.load(); initTableRowsColumns(); extractExistingNames(); } catch (Exception ex) { LOG.error("Error setting UI", ex); } }
From source file:com.toyota.carservice.config.config2.java
public Object loadAnchorPane(AnchorPane ap, String a) { try {//ww w. ja v a 2s .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:sonicScream.controllers.CategoryTabController.java
public CategoryTabController(Category category) { URL location = getClass().getResource("/sonicScream/views/CategoryTab.fxml"); FXMLLoader loader = new FXMLLoader(location); loader.setRoot(this); loader.setController(this); try {/*from ww w .ja va 2 s. co m*/ loader.load(); } catch (IOException ex) { throw new RuntimeException(ex); } _category = category; this.textProperty().bind(_category.categoryNameProperty()); CategoryTabComboBox.setItems(_category.getCategoryScripts()); //These two bindings handle changing between categories with only a single //script (items) and those with multiple (everything else) SimpleListProperty bindableList = new SimpleListProperty(); bindableList.bind(new SimpleObjectProperty<>(_category.getCategoryScripts())); CategoryTabComboBox.visibleProperty().bind(Bindings.greaterThan(bindableList.sizeProperty(), 1)); selectedScriptNodeProperty().bind(CategoryTabTreeView.getSelectionModel().selectedItemProperty()); selectedScript.bind(CategoryTabComboBox.getSelectionModel().selectedItemProperty()); if (_category.getCategoryScripts() != null && !_category.getCategoryScripts().isEmpty()) { CategoryTabComboBox.valueProperty().set(_category.getCategoryScripts().get(0)); handleComboBoxChanged(null); } SwapDisplayModeButton.textProperty().bind(Bindings.when(displayMode.isEqualTo(CategoryDisplayMode.SIMPLE)) .then("Advanced >>").otherwise("<< Simple")); CategoryTabTreeView.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> { if (newValue != null) { TreeItem<String> scriptValue = TreeUtils.getRootMinusOne((TreeItem<String>) newValue); TreeItem<String> selectedValue = (TreeItem<String>) newValue; CategoryTabScriptValueLabel.setText(scriptValue.getValue()); selectedScriptNodeIsLeaf.set(selectedValue.isLeaf()); } }); }
From source file:aajavafx.MedicinesController.java
@FXML private void handleBackButton(ActionEvent event) { try {//from w w w. ja v a 2s . c o m Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPage.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); System.out.println("You clicked Schedule!"); } catch (Exception ex) { System.out.println("ERROR! " + ex); } }
From source file:org.sleuthkit.autopsy.timeline.ShowInTimelineDialog.java
/** * Common Private Constructor//from w w w . j av a 2 s . c o m * * @param controller The controller for this Dialog. * @param eventIDS A List of eventIDs to present to the user to choose * from. */ @NbBundle.Messages({ "ShowInTimelineDialog.amountValidator.message=The entered amount must only contain digits." }) private ShowInTimelineDialog(TimeLineController controller, List<Long> eventIDS) { this.controller = controller; //load dialog content fxml final String name = "nbres:/" + StringUtils.replace(ShowInTimelineDialog.class.getPackage().getName(), ".", "/") + "/ShowInTimelineDialog.fxml"; // NON-NLS try { FXMLLoader fxmlLoader = new FXMLLoader(new URL(name)); fxmlLoader.setRoot(contentRoot); fxmlLoader.setController(this); fxmlLoader.load(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Unable to load FXML, node initialization may not be complete.", ex); //NON-NLS } //assert that fxml loading happened correctly assert eventTable != null : "fx:id=\"eventTable\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert typeColumn != null : "fx:id=\"typeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert dateTimeColumn != null : "fx:id=\"dateTimeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert amountSpinner != null : "fx:id=\"amountsSpinner\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert unitComboBox != null : "fx:id=\"unitChoiceBox\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; //validat that spinner has a integer in the text field. validationSupport.registerValidator(amountSpinner.getEditor(), false, Validator.createPredicateValidator( NumberUtils::isDigits, Bundle.ShowInTimelineDialog_amountValidator_message())); //configure dialog properties PromptDialogManager.setDialogIcons(this); initModality(Modality.APPLICATION_MODAL); //add scenegraph loaded from fxml to this dialog. DialogPane dialogPane = getDialogPane(); dialogPane.setContent(contentRoot); //add buttons to dialog dialogPane.getButtonTypes().setAll(SHOW, ButtonType.CANCEL); ///configure dialog controls amountSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1000)); amountSpinner.getValueFactory().setConverter(new IntegerStringConverter() { /** * Convert the String to an Integer using Integer.valueOf, but if * that throws a NumberFormatException, reset the spinner to the * last valid value. * * @param string The String to convert * * @return The Integer value of string. */ @Override public Integer fromString(String string) { try { return super.fromString(string); } catch (NumberFormatException ex) { return amountSpinner.getValue(); } } }); unitComboBox.setButtonCell(new ChronoFieldListCell()); unitComboBox.setCellFactory(comboBox -> new ChronoFieldListCell()); unitComboBox.getItems().setAll(SCROLL_BY_UNITS); unitComboBox.getSelectionModel().select(ChronoField.MINUTE_OF_HOUR); typeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getEventType())); typeColumn.setCellFactory(param -> new TypeTableCell<>()); dateTimeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getStartMillis())); dateTimeColumn.setCellFactory(param -> new DateTimeTableCell<>()); //add events to table eventTable.getItems().setAll( eventIDS.stream().map(controller.getEventsModel()::getEventById).collect(Collectors.toSet())); eventTable.setPrefHeight(Math.min(200, 24 * eventTable.getItems().size() + 28)); }
From source file:ExcelFx.FXMLDocumentController.java
@FXML private void Open(ActionEvent event) throws NullPointerException, IOException { System.out.println("-----------------------------------------------------------"); System.out.println("Pressed open Button "); File universityFile = new File("university.json"); File collegeFile = new File("college.json"); System.out.println("University File emty is " + String.valueOf(universityFile.length() == 0)); System.out.println("College File emty is " + String.valueOf(collegeFile.length() == 0)); //File codesFile = new File("codes.json"); if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) { try {//from w w w . j ava2 s . c o m this.universityJson.jsonRead("university.json"); this.collegeJson.jsonRead("college.json"); //this.codesJson.jsonRead("codes.json"); this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/); } catch (IOException | ParseException ex) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(""); alert.setHeaderText(" ? ? "); alert.setContentText(ex.toString()); alert.showAndWait(); Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex); } } else { try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FileOpenFXML.fxml")); this.fileOpenParent = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.DECORATED); stage.setTitle(" "); stage.setScene(new Scene(this.fileOpenParent)); stage.showAndWait(); } catch (Exception e) { System.err.println(e); } this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/); } FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("InitalData.fxml")); Parent root1 = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.DECORATED); stage.setTitle(" "); stage.setScene(new Scene(root1)); stage.showAndWait(); setProgressBar(-1.); Task task = new Task<Void>() { @Override protected Void call() throws Exception { initaldata = (JsonWrite) root1.getUserData(); System.out.println("Inital Data empty is " + initaldata.isEmpty()); initaldata.setPage(String.valueOf(Integer.parseInt(initaldata.getPage()) - 1)); Parser parser = new Parser(); list = parser.parseInitalData(initaldata.getPatch(), Integer.parseInt(initaldata.getPage())); //System.out.println(list.size()); Sort sort = new Sort(list, jsonXLSXData, initaldata.getYStart(), initaldata.getYEnd()); HashMap<String, HashMap<String, ArrayList<String>>> hm = sort .professionsGrouping(initaldata.getYStart(), initaldata.getYEnd()); sortProf = sort.addWay(hm); return null; } }; mainProcessing(task); System.out.println("button open finished"); System.out.println("-----------------------------------------------------------"); }
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 w ww. j av a 2 s.com 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); } }