List of usage examples for javafx.fxml FXMLLoader FXMLLoader
public FXMLLoader(Charset charset)
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. jav a 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; }
From source file:gov.va.isaac.gui.listview.operations.FindAndReplace.java
@Override public void init(ObservableList<SimpleDisplayConcept> conceptList) { super.init(conceptList); try {/* w ww. j a va 2 s .c o m*/ URL resource = FindAndReplace.class.getResource("FindAndReplaceController.fxml"); FXMLLoader loader = new FXMLLoader(resource); loader.load(); frc_ = loader.getController(); super.root_ = frc_.getRoot(); } catch (IOException e) { logger_.error("Unexpected error building panel", e); throw new RuntimeException("Error building panel"); } }
From source file:io.github.mzmine.util.jfreechart.ManualZoomDialog.java
/** * Constructor/*from w w w .j a v a 2s.co m*/ */ public ManualZoomDialog(Window parent, XYPlot plot) { initOwner(parent); setTitle("Manual zoom"); setGraphic(new ImageView("file:icons/axesicon.png")); getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); xAxis = (NumberAxis) plot.getDomainAxis(); yAxis = (NumberAxis) plot.getRangeAxis(); try { URL layersDialogFXML = getClass().getResource(DIALOG_FXML); FXMLLoader loader = new FXMLLoader(layersDialogFXML); loader.setController(this); GridPane grid = loader.load(); getDialogPane().setContent(grid); } catch (Exception e) { e.printStackTrace(); } final Button btOk = (Button) getDialogPane().lookupButton(ButtonType.OK); btOk.addEventFilter(ActionEvent.ACTION, event -> { commitChanges(event); }); }
From source file:jlotoprint.MainViewController.java
public static Stage loadTemplateChooser() { final Stage stage = new Stage(); try {// w w w . j a v a 2s .co m FXMLLoader dialog = new FXMLLoader(MainViewController.class.getResource("TemplateDialog.fxml")); Parent root = (Parent) dialog.load(); root.addEventHandler(TemplateDialogEvent.CANCELED, (actionEvent) -> { stage.close(); }); stage.setScene(new Scene(root)); stage.setTitle("Choose a template"); stage.getIcons().add(new Image("file:resources/icon.png")); stage.initModality(Modality.WINDOW_MODAL); stage.initOwner(JLotoPrint.stage.getScene().getWindow()); stage.show(); } catch (IOException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); return null; } return stage; }
From source file:org.kordamp.javatrove.example04.view.AppView.java
public Scene createScene() { String basename = getClass().getPackage().getName().replace('.', '/') + "/app"; URL fxml = getClass().getClassLoader().getResource(basename + ".fxml"); FXMLLoader fxmlLoader = new FXMLLoader(fxml); fxmlLoader.setControllerFactory(param -> AppView.this); Parent root = null;/* www . ja va 2 s . c om*/ try { root = (Parent) fxmlLoader.load(); } catch (IOException e) { throw new IllegalStateException(e); } organization.textProperty().addListener((observable, oldValue, newValue) -> { model.setState(isBlank(newValue) ? DISABLED : READY); }); model.stateProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> { switch (newValue) { case DISABLED: enabled.setValue(false); running.setValue(false); break; case READY: enabled.setValue(true); running.setValue(false); break; case RUNNING: enabled.setValue(false); running.setValue(true); break; } })); ObservableList<Repository> items = createJavaFXThreadProxyList(model.getRepositories().sorted()); repositories.setItems(items); EventStreams.sizeOf(items).subscribe(v -> total.setText(String.valueOf(v))); organization.textProperty().bindBidirectional(model.organizationProperty()); bindBidirectional(limit.textProperty(), model.limitProperty(), new NumberStringConverter()); loadButton.disableProperty().bind(Bindings.not(enabled)); cancelButton.disableProperty().bind(Bindings.not(running)); progress.visibleProperty().bind(running); Scene scene = new Scene(root); scene.getStylesheets().addAll(basename + ".css", "bootstrapfx.css"); return scene; }
From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java
public static ComplexQueryViewController createComplexQueryView(ProjectView pv) { Scene scene;//from ww w .j a va 2 s . com FXMLLoader loader = new FXMLLoader( TabularDataViewController.class.getResource("/fxml/ComplexQueryView.fxml")); AnchorPane ap; try { ap = (AnchorPane) loader.load(); } catch (IOException e) { throw new RuntimeException("Could not load internal file 'ComplexQueryView.fxml': " + e); } scene = new Scene(ap); ComplexQueryViewController controller = loader.getController(); controller.scene = scene; controller.projectView = pv; return controller; }
From source file:com.toyota.carservice.config.config2.java
public Object newStage3(Stage stage, Label lb, String load, String judul, boolean resize, StageStyle style, boolean maximized) { try {/*from w w w .jav a 2 s . c o m*/ Stage st = new Stage(); stage = (Stage) lb.getScene().getWindow(); FXMLLoader root = new FXMLLoader(getClass().getResource(load)); Scene scene = new Scene(root.load()); st.initStyle(style); st.setResizable(resize); st.setMaximized(maximized); st.setTitle(judul); st.setScene(scene); ApplicationContext appContex = config.getInstance().getApplicationContext(); Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png"); st.getIcons().add(new Image(resource.getURI().toString())); st.show(); return root.getController(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:aajavafx.LoginController.java
@FXML private void handleButtonLoginAction(ActionEvent event) { try {//from ww w .j a v a 2s. c om username_var = userID.getText().toString(); password_var = passwordID.getText().toString(); Kripto myKripto = new Kripto(); System.out.println(myKripto.encrypt(password_var)); if (saveCredentials.isSelected()) { UserCredentials userCred = new UserCredentials(username_var, password_var); try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(savedCredentials))) { out.writeObject(userCred); } catch (IOException ex) { System.out.println("IO Exception: " + ex); } catch (Exception ex) { System.out.println("Exception: " + ex); ; } } //////Check password disabled // String passwordCypherFromDB = getPassword(username_var); // String passwordFromDB = myKripto.decrypt(passwordCypherFromDB); // if (passwordFromDB.equals(password_var)) { Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPageTab.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); System.out.println("Taking you to next page!"); // } else { // outputmessageID.setText("Login failed!!!!"); // } } catch (Exception ex) { System.out.println("LOAD PAGE EXCEPTION: " + ex); } System.out.println("You clicked me!"); }
From source file:de.mirkosertic.desktopsearch.DesktopSearch.java
@Override public void start(Stage aStage) throws Exception { // This is our base directory File theBaseDirectory = new File(SystemUtils.getUserHome(), "FreeSearchIndexDir"); theBaseDirectory.mkdirs();/* w w w. ja v a2s. c o m*/ configurationManager = new ConfigurationManager(theBaseDirectory); Notifier theNotifier = new Notifier(); stage = aStage; // Create the known preview processors PreviewProcessor thePreviewProcessor = new PreviewProcessor(); try { // Boot the search backend and set it up for listening to configuration changes backend = new Backend(theNotifier, configurationManager.getConfiguration(), thePreviewProcessor); configurationManager.addChangeListener(backend); // Boot embedded JSP container embeddedWebServer = new FrontendEmbeddedWebServer(aStage, backend, thePreviewProcessor, configurationManager); embeddedWebServer.start(); } catch (BindException | LockReleaseFailedException | LockObtainFailedException e) { // In this case, there is already an instance of DesktopSearch running // Inform the instance to bring it to front end terminate the current process. URL theURL = new URL(FrontendEmbeddedWebServer.getBringToFrontUrl()); // Retrieve the content, but it can be safely ignored // There must only be the get request Object theContent = theURL.getContent(); // Terminate the JVM. The window of the running instance is visible now. System.exit(0); } aStage.setTitle("Free Desktop Search"); aStage.setWidth(800); aStage.setHeight(600); aStage.initStyle(StageStyle.TRANSPARENT); FXMLLoader theLoader = new FXMLLoader(getClass().getResource("/scenes/mainscreen.fxml")); AnchorPane theMainScene = theLoader.load(); final DesktopSearchController theController = theLoader.getController(); theController.configure(this, backend, FrontendEmbeddedWebServer.getSearchUrl(), stage.getOwner()); Undecorator theUndecorator = new Undecorator(stage, theMainScene); theUndecorator.getStylesheets().add("/skin/undecorator.css"); Scene theScene = new Scene(theUndecorator); // Hacky, but works... theUndecorator.setStyle("-fx-background-color: rgba(0, 0, 0, 0);"); theScene.setFill(Color.TRANSPARENT); aStage.setScene(theScene); aStage.getIcons().add(new Image(getClass().getResourceAsStream("/fds.png"))); if (SystemTray.isSupported()) { Platform.setImplicitExit(false); SystemTray theTray = SystemTray.getSystemTray(); // We need to reformat the icon according to the current tray icon dimensions // this depends on the underlying OS java.awt.Image theTrayIconImage = Toolkit.getDefaultToolkit() .getImage(getClass().getResource("/fds_small.png")); int trayIconWidth = new TrayIcon(theTrayIconImage).getSize().width; TrayIcon theTrayIcon = new TrayIcon( theTrayIconImage.getScaledInstance(trayIconWidth, -1, java.awt.Image.SCALE_SMOOTH), "Free Desktop Search"); theTrayIcon.setImageAutoSize(true); theTrayIcon.setToolTip("FXDesktopSearch"); theTrayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 1) { Platform.runLater(() -> { if (stage.isIconified()) { stage.setIconified(false); } stage.show(); stage.toFront(); }); } } }); theTray.add(theTrayIcon); aStage.setOnCloseRequest(aEvent -> stage.hide()); } else { aStage.setOnCloseRequest(aEvent -> shutdown()); } aStage.setMaximized(true); aStage.show(); }