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:com.esri.geoevent.test.performance.ui.OrchestratorController.java

/**
 * Shows the confirmation dialog//from   w w w .ja v a2s .  co  m
 */
private boolean showConfirmationDialog(String msg) {
    try {
        // Load the fxml file and create a new stage for the popup
        FXMLLoader loader = new FXMLLoader(getClass().getResource("ConfirmationDialog.fxml"));
        Parent page = (Parent) loader.load();
        Stage dialogStage = new Stage();
        dialogStage.setTitle(UIMessages.getMessage("UI_CLOSE_TAB_TITLE"));
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        dialogStage.initOwner(stage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        // Set the person into the controller
        ConfirmationDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setConfirmationMsg(msg);

        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();
        return controller.isOkClicked();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:aajavafx.CustomerController.java

@FXML
private void handleGoBack(ActionEvent event) {
    //labelError.setText(null);
    try {// 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, 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

/**
 * Perform functionality associated with "About" menu selection or CTRL-A.
 *///from  w w  w  .j  a  v  a2  s  .  c  o m
private void provideAboutFunctionality() {
    try {
        // Load the fxml file and create a new stage for the popup
        FXMLLoader loader = new FXMLLoader(getClass().getResource("AboutDialog.fxml"));
        Parent page = (Parent) loader.load();
        Stage dialogStage = new Stage();
        dialogStage.setTitle(UIMessages.getMessage("UI_HELP_ABOUT_MENU_ITEM_LABEL"));
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        dialogStage.initOwner(stage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        // Set the person into the controller
        AboutDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);

        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:ExcelFx.FXMLDocumentController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    this.Print.setDisable(true);

    footer.setItems(names);/*from w w w  .  j av  a2  s  . c  o  m*/
    JsonWrite jsw = new JsonWrite();
    File universityFile = new File("university.json");
    File collegeFile = new File("college.json");
    //File codesFile = new File("codes.json");

    if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) {
        try {
            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*/);
    }

}

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

/**
 * Perform functionality associated with "About" menu selection or CTRL-A.
 *//*w ww.  jav a  2  s. c  om*/
private void showLoggerDialog() {
    try {
        // Load the fxml file and create a new stage for the popup
        FXMLLoader loader = new FXMLLoader(getClass().getResource("LoggerDialog.fxml"));
        Parent page = (Parent) loader.load();
        Stage dialogStage = new Stage();
        dialogStage.setTitle(UIMessages.getMessage("UI_LOGGER_BOX_LABEL"));
        dialogStage.initModality(Modality.NONE);
        dialogStage.initOwner(stage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        // Set the person into the controller
        LoggerDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setOutputBuffer(outputBuffer.toString());
        controller.onClearLoggerEvent(() -> outputBuffer = new StringBuffer());

        // Show the dialog
        dialogStage.show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

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

private void addFixtureTab(final Fixture fixture, boolean isDefault) {
    try {//from w w  w  . ja v  a  2s .c  o  m
        FXMLLoader loader = new FXMLLoader(getClass().getResource("Fixture.fxml"));
        Parent fixtureTab = (Parent) loader.load();

        FixtureController controller = loader.getController();
        controller.setFixture(fixture);
        controller.setIsDefault(isDefault);

        Tab newTab = new Tab(fixture.getName());
        newTab.setContent(fixtureTab);
        newTab.closableProperty().setValue(!isDefault);
        newTab.setOnCloseRequest(event -> {
            boolean isOkClicked = showConfirmationDialog(
                    UIMessages.getMessage("UI_CLOSE_TAB_LABEL", fixture.getName()));
            if (!isOkClicked) {
                event.consume();
            } else {
                fixtures.getFixtures().remove(fixture);
            }
        });
        fixtureTabPane.getTabs().add(newTab);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java

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

From source file:view.FXApplicationController.java

@FXML
protected void aboutAction() {
    Stage stage = new Stage();
    AnchorPane addGrid = new AnchorPane();

    // Creating FXML Loader
    FXMLLoader loader = new FXMLLoader(FXStartController.class.getResource("About.fxml"));
    loader.setController(this);

    // Try to load fxml file
    try {// ww w.java  2s  . c  o m
        addGrid = loader.load();
    } catch (IOException e) {
        System.err.println("Error during loading About.fxml file!");
    }

    Scene scene = new Scene(addGrid);

    stage.setResizable(false);
    stage.setScene(scene);

    stage.show();

    stage.setTitle("About");
}

From source file:genrsa.GenRSAController.java

/**
 * Mtodo usado para cargar la ventana de Factorizacin
 * @param event // ww w  .j  a  va 2 s  . c om
 */
public void Factorize(ActionEvent event) {
    FXMLLoader fxmlLoader;
    Parent root;

    try {
        secondStage = new Stage();
        fxmlLoader = new FXMLLoader(getClass().getResource("/Factorize/Factorize.fxml"));
        root = fxmlLoader.load();

        FactorizeController factorController = fxmlLoader.<FactorizeController>getController();
        factorController.setRadix(this.radix);

        if (this.RSA != null) {
            factorController.getModulus().setText(this.RSA.getN().toString(this.radix).toUpperCase());
        }

        disableOnProgress(true);

        Scene scene = new Scene(root);
        secondStage.initModality(Modality.NONE);
        secondStage.getIcons()
                .add(new Image(GenRSAController.class.getResourceAsStream("/allImages/genRSA.png")));
        secondStage.setTitle("genRSA - Ataque por Factorizacin");
        secondStage.setScene(scene);
        secondStage.show();

        secondStage.setOnCloseRequest(closeEvent -> {
            factorController.getFactorizeAttack().setIsCancelled(true);
            this.disableOnProgress(false);
            this.disableButtons();
        });

    } catch (IOException ex) {
        //no pongo mensaje de error, porque no se puede dar el caso
    }

}