Example usage for javafx.fxml FXMLLoader FXMLLoader

List of usage examples for javafx.fxml FXMLLoader FXMLLoader

Introduction

In this page you can find the example usage for javafx.fxml FXMLLoader FXMLLoader.

Prototype

public FXMLLoader(Charset charset) 

Source Link

Document

Creates a new FXMLLoader instance.

Usage

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

private void initGenerateXPathFromStackTrace() {

    ContextMenu menu = new ContextMenu();

    MenuItem item = new MenuItem("Generate from stack trace...");
    item.setOnAction(e -> {/*from w w w .ja  va  2s .c  om*/
        try {
            Stage popup = new Stage();
            FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml"));
            Parent root = loader.load();
            Button button = (Button) loader.getNamespace().get("generateButton");
            TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea");

            ValidationSupport validation = new ValidationSupport();

            validation.registerValidator(area,
                    Validator.createEmptyValidator("The stack trace may not be empty"));
            button.disableProperty().bind(validation.invalidProperty());

            button.setOnAction(f -> {
                DesignerUtil.stackTraceToXPath(area.getText()).ifPresent(xpathExpressionArea::replaceText);
                popup.close();
            });

            popup.setScene(new Scene(root));
            popup.initStyle(StageStyle.UTILITY);
            popup.initModality(Modality.WINDOW_MODAL);
            popup.initOwner(designerRoot.getMainStage());
            popup.show();
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
    });

    menu.getItems().add(item);

    xpathExpressionArea.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
        if (t.getButton() == MouseButton.SECONDARY) {
            menu.show(xpathExpressionArea, t.getScreenX(), t.getScreenY());
        }
    });
}

From source file:acmi.l2.clientmod.xdat.Controller.java

private Node loadScriptTabContent() {
    try {/*from w w  w . j  a va  2s . c  o m*/
        FXMLLoader loader = new FXMLLoader(getClass().getResource("scripting/main.fxml"));
        loader.setClassLoader(getClass().getClassLoader());
        loader.setControllerFactory(param -> new acmi.l2.clientmod.xdat.scripting.Controller(editor));
        return wrap(loader.load());
    } catch (IOException e) {
        log.log(Level.WARNING, "Couldn't load script console", e);
    }
    return null;
}

From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java

public void handleSetupLayers(Event e) {
    try {/*from   w w w .  j a  v a2  s.  c  o m*/
        URL layersDialogFXML = getClass().getResource(LAYERS_DIALOG_FXML);
        FXMLLoader loader = new FXMLLoader(layersDialogFXML);
        Stage layersDialog = loader.load();
        ChromatogramLayersDialogController controller = loader.getController();
        controller.configure(datasets, this);
        layersDialog.initModality(Modality.APPLICATION_MODAL);
        layersDialog.show();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.github.drbookings.DrBookingsApplication.java

private void startGUI(final Stage stage) throws IOException {
    final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/MainView.fxml"));
    final Parent root = loader.load();
    final Scene scene = new Scene(root, 900, 800);
    mainController = loader.getController();
    String s = getClass().getPackage().getImplementationVersion();
    if (s == null) {
        s = "dev version";
    }//from w w w  . j  a va  2 s.  c  om
    stage.setTitle("Dr.Bookings " + s);
    stage.setScene(scene);
    stage.setOnCloseRequest(new CloseRequestEventHandler());
    stage.show();
    mainController.readDataFile(SettingsManager.getInstance().getDataFile());

}

From source file:spdxedit.PackageEditor.java

/**
 * Opens the modal package editor for the provided package.
 *
 * @param pkg               The package to edit.
 * @param relatablePackages Packages to which the edited package may optionally have defined relationships
 * @param parentWindow      The parent window.
 *//*from   www  .  j  ava  2s.co  m*/
public static void editPackage(final SpdxPackage pkg, final List<SpdxPackage> relatablePackages,
        SpdxDocumentContainer documentContainer, Window parentWindow) {

    final PackageEditor packageEditor = new PackageEditor(pkg, relatablePackages, documentContainer);
    final Stage dialogStage = new Stage();
    dialogStage.setTitle("Edit SPDX Package: " + pkg.getName());
    dialogStage.initStyle(StageStyle.DECORATED);
    dialogStage.initModality(Modality.APPLICATION_MODAL);
    dialogStage.setY(parentWindow.getX() + parentWindow.getWidth() / 2);
    dialogStage.setY(parentWindow.getY() + parentWindow.getHeight() / 2);
    dialogStage.setResizable(false);
    try {
        FXMLLoader loader = new FXMLLoader(NewPackageDialog.class.getResource("/PackageEditor.fxml"));
        loader.setController(packageEditor);
        Pane pane = loader.load();
        Scene scene = new Scene(pane);
        dialogStage.setScene(scene);
        dialogStage.getIcons().clear();
        dialogStage.getIcons().add(UiUtils.ICON_IMAGE_VIEW.getImage());
        //Populate the file list on appearance
        dialogStage.setOnShown(event -> {
            try {
                final SpdxFile dummyfile = new SpdxFile(pkg.getName(), null, null, null, null, null, null, null,
                        null, null, null, null, null);
                TreeItem<SpdxFile> root = new TreeItem<>(dummyfile);
                packageEditor.filesTable.setRoot(root);
                //Assume a package without is external
                //TODO: replace with external packages or whatever alternate mechanism in 2.1
                packageEditor.btnAddFile.setDisable(pkg.getFiles().length == 0);
                root.getChildren()
                        .setAll(Stream.of(pkg.getFiles())
                                .sorted(Comparator.comparing(file -> StringUtils.lowerCase(file.getName()))) //Sort by file name
                                .map(TreeItem<SpdxFile>::new).collect(Collectors.toList()));
            } catch (InvalidSPDXAnalysisException e) {
                logger.error("Unable to get files for package " + pkg.getName(), e);
            }

            packageEditor.tabFiles.setExpanded(true);

        });

        //Won't assign this event through FXML - don't want to propagate the stage beyond this point.
        packageEditor.btnOk.setOnMouseClicked(event -> dialogStage.close());
        dialogStage.showAndWait();

    } catch (IOException ioe) {
        throw new RuntimeException("Unable to load dialog", ioe);
    }
}

From source file:aajavafx.CustomerMedicineController.java

@FXML
private void handleBackButton(ActionEvent event) {
    try {/*from   w ww .j a v a 2s  . c  o  m*/

        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("You clicked Schedule!");
    } catch (Exception ex) {

        System.out.println("ERROR! " + ex);
    }
}

From source file:aajavafx.VisitorController.java

@FXML
private void handleGoBack(ActionEvent event) {
    try {/* www.  j av  a 2 s . com*/
        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, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java

/**
 * Shows the report options dialog//  w ww.  j a  v  a 2s  .  c o  m
 */
private void showReportOptionsDialog() {
    try {
        // Load the fxml file and create a new stage for the popup
        FXMLLoader loader = new FXMLLoader(getClass().getResource("ReportOptions.fxml"));
        AnchorPane page = (AnchorPane) loader.load();
        Stage dialogStage = new Stage();
        dialogStage.setTitle(UIMessages.getMessage("UI_REPORT_OPTIONS_TITLE"));
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        dialogStage.initOwner(stage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        // Set the person into the controller
        ReportOptionsController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setReport(this.fixtures.getReport()); //TODO: we need to clone our Report Object Here

        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();
        if (controller.isOkClicked()) {
            this.fixtures.setReport(controller.getReport());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

public void showExportXPathToRuleWizard() throws IOException {
    ExportXPathWizardController wizard = new ExportXPathWizardController(xpathExpressionProperty());

    FXMLLoader loader = new FXMLLoader(getClass().getResource("fxml/xpath-export-wizard.fxml"));
    loader.setController(wizard);/*w ww .  ja  va  2  s . c  o m*/

    final Stage dialog = new Stage();
    dialog.initOwner(designerRoot.getMainStage());
    dialog.setOnCloseRequest(e -> wizard.shutdown());
    dialog.initModality(Modality.WINDOW_MODAL);

    Parent root = loader.load();
    Scene scene = new Scene(root);
    //stage.setTitle("PMD Rule Designer (v " + PMD.VERSION + ')');
    dialog.setScene(scene);
    dialog.show();
}