Example usage for javafx.fxml FXMLLoader load

List of usage examples for javafx.fxml FXMLLoader load

Introduction

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

Prototype

public static <T> T load(URL location) throws IOException 

Source Link

Document

Loads an object hierarchy from a FXML document.

Usage

From source file:org.pdfsam.community.PdfsamCommunityConfig.java

@Bean(name = "logo")
public Group logo() throws IOException {
    Resource resource = new ClassPathResource("/fxml/LogoCommunity.fxml");
    return FXMLLoader.load(resource.getURL());
}

From source file:gmailclientfx.controllers.LoginController.java

public void btnLogin_click(ActionEvent e) {
    if (!txtEmail.getText().equals("")) {
        String email = txtEmail.getText();
        if (EmailValidator.getInstance().isValid(email)) {
            User user = User.getUserByEmail(email);

            if (!(user == null)) {
                try {

                    GmailClient.setRefreshToken(user.getRefreshToken());
                    GmailClient.refreshAccessToken();

                    Parent loginStage = txtEmail.getParent();
                    loginStage.getScene().getWindow().hide();
                    Parent root;//from w ww  .j  av a  2  s  .  c  om
                    root = FXMLLoader
                            .load(getClass().getClassLoader().getResource("gmailclientfx/views/Home.fxml"));
                    Stage stage = new Stage();
                    stage.setTitle("Home");
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent e) {
                            Platform.exit();
                            System.exit(0);

                        }
                    });
                    stage.setScene(new Scene(root));
                    stage.show();
                } catch (IOException ex) {
                    Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
                }

            } else {
                try {
                    GmailClient.authorizeUser();
                    String noviEmail = GmailClient.getEmail();
                    String noviRefreshToken = GmailClient.getRefreshToken();
                    User u = User.getUserByEmail(noviEmail);

                    if (u == null) {
                        User.unesiUseraUBazu(new User(noviEmail, noviRefreshToken));
                    }

                    Parent loginStage = txtEmail.getParent();
                    loginStage.getScene().getWindow().hide();
                    Parent root;
                    root = FXMLLoader
                            .load(getClass().getClassLoader().getResource("gmailclientfx/views/Home.fxml"));
                    Stage stage = new Stage();
                    stage.setTitle("Home");
                    stage.setScene(new Scene(root));
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent e) {
                            Platform.exit();
                            System.exit(0);

                        }
                    });
                    stage.show();

                } catch (IOException ex) {
                    Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        } else {
            lblStatusMsg.setText("Uneseni email nije validan!");
        }
    } else {
        lblStatusMsg.setText("Unesite email!");
    }
}

From source file:com.kotcrab.vis.editor.CrashReporter.java

@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("crash-reporter-layout.fxml"));

    Scene scene = new Scene(root);

    stage.setTitle("VisEditor Crash Reporter");
    stage.getIcons().add(new Image(CrashReporter.class.getResourceAsStream("icon.png")));
    stage.setScene(scene);/*from  w  w  w  .  ja  v a  2s  . c o m*/
    stage.setResizable(false);
    stage.sizeToScene();
    stage.show();
}

From source file:memoryaid.GalleryController.java

@FXML
private void uploadImageAction(ActionEvent event) throws IOException {
    String imgPath = imagePathText.getText();
    String baseName = FilenameUtils.getBaseName(imgPath);

    String destinationPath = "/Users/madhaviunnam/NetBeansProjects/MemoryAid/src/GalleryImages";
    File destinationPathObject = new File(destinationPath + "/" + baseName + ".png");
    File sourceFilePathObject = new File(imgPath);
    FileUtils.copyFile(sourceFilePathObject, destinationPathObject);
    Parent Gallery = FXMLLoader.load(getClass().getResource("Gallery1.fxml"));
    Scene Gallery_scene = new Scene(Gallery);
    Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
    app_stage.hide();//from  ww  w .j a va2  s  .  co  m
    app_stage.setScene(Gallery_scene);
    app_stage.show();
}

From source file:smarthome.FXMLDocumentController.java

@FXML
private void pwdChangeButtonAction(ActionEvent event) {

    Stage stage = new Stage();
    //Fill stage with content
    stage.setTitle("New Window");

    stage.setTitle("Smart Home");
    Parent root;//from w ww .j a  v a  2  s  .  com
    try {
        root = FXMLLoader.load(getClass().getResource("changeUserPasswd.fxml"));
        Undecorator undecorator = new Undecorator(stage, (Region) root);
        undecorator.getStylesheets().add("skin/undecorator.css");
        Scene scene = new Scene(undecorator);
        stage.setScene(scene);
        scene.setFill(Color.TRANSPARENT);
        stage.initStyle(StageStyle.TRANSPARENT);
        stage.setScene(scene);
        stage.setResizable(false);
        stage.show();

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

}

From source file:br.com.ajaio.midas.desktop.controller.DashBoardController.java

public void addConta() throws IOException {
    Stage stage = new Stage();
    Parent root = FXMLLoader.load(MainApp.class.getResource("view/popContaFormFXML.fxml"));
    stage.setTitle("Add new entry");
    stage.setScene(new Scene(root, 800, 600));
    stage.show();//from   ww  w  . j a va 2s  .c  o  m
}

From source file:account.management.controller.ViewSalaryVoucherController.java

/**
 * Initializes the controller class.//from   ww w.  j  a v  a2 s .c  o  m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    this.voucher_no.setCellValueFactory(new PropertyValueFactory("id"));
    this.date.setCellValueFactory(new PropertyValueFactory("date"));
    this.section.setCellValueFactory(new PropertyValueFactory("section"));
    this.name.setCellValueFactory(new PropertyValueFactory("name"));
    this.basis.setCellValueFactory(new PropertyValueFactory("basis"));
    this.amount.setCellValueFactory(new PropertyValueFactory("total"));

    final ContextMenu contextMenu = new ContextMenu();
    MenuItem item1 = new MenuItem("    View                  ");
    item1.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Data.salaryVoucher = table.getSelectionModel().getSelectedItem();

            try {
                Parent root = FXMLLoader
                        .load(getClass().getResource(MetaData.viewPath + "EditSalaryVoucher.fxml"));
                Scene scene = new Scene(root);
                Stage stage = new Stage();
                scene.setRoot(root);
                stage.setResizable(false);
                stage.setTitle("Salary Voucher");
                stage.setScene(scene);
                stage.showAndWait();
                int index = table.getSelectionModel().getSelectedIndex();
                getData();

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

        }
    });
    contextMenu.getItems().addAll(item1);
    this.table.setContextMenu(contextMenu);

}

From source file:tworpus.client.mainwindow.MainWindowController.java

@FXML
public void showVisualizations() {
    System.out.println("show visualizations");
    //initWebView();
    //test();//w ww.j a v  a  2 s  .  c  o m

    try {
        Pane pane = FXMLLoader.load(visualizationsFXML);
        maincontent = pane;
        borderPane.centerProperty().set(maincontent);
    } catch (IOException ex) {
        Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex);
        ex.printStackTrace();
    }
}

From source file:main.TestManager.java

/**
 * Displays a screen on which teacher can create a new test.
 * @param stage current stage/* www .ja  v a 2s .c  o  m*/
 */
public static void displayCreateNew(Stage stage) {
    try {
        Parent pane = FXMLLoader.load(TestManager.class.getResource("/resources/FXMLNewTest.fxml"));
        stage.setScene(new Scene(pane));
        stage.show();
    } catch (IOException e) {
        ErrorInformer.exitApp();
    }
}

From source file:account.management.controller.loginController.java

@FXML
private void onLoginButtonClick(ActionEvent event) {
    try {/*from   w  w  w .ja  va2  s.co m*/

        String username = this.username.getText();
        String password = this.password.getText();

        User.username = username;

        this.login_btn.setDisable(true);
        this.login_btn.setText("Loading...");
        Thread t = new Thread(() -> {
            try {
                HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "login")
                        .queryString("username", username).queryString("password", password).asJson();
                JSONArray array = res.getBody().getArray();
                JSONObject obj = array.getJSONObject(0);
                if (obj.getInt("inventory") == 1)
                    User.inventory = true;
                if (obj.getInt("project") == 1)
                    User.project = true;
                if (obj.getInt("lc") == 1)
                    User.lc = true;
                if (obj.getInt("cnf") == 1)
                    User.cnf = true;
                if (obj.getInt("deposit_voucher") == 1)
                    User.deposit_voucher = true;
                if (obj.getInt("expense_voucher") == 1)
                    User.expense_voucher = true;
                if (obj.getInt("sell") == 1)
                    User.sell = true;
                if (obj.getInt("purchase") == 1)
                    User.purchase = true;
                if (obj.getInt("party_create") == 1)
                    User.party_create = true;
                if (obj.getInt("ledger_create") == 1)
                    User.ledger = true;
                if (obj.getInt("voucher") == 1)
                    User.voucher = true;
                if (obj.getInt("bank") == 1)
                    User.bank = true;
                if (obj.getInt("inventory_report") == 1)
                    User.inventory_report = true;
                if (obj.getInt("trial_balance") == 1)
                    User.trial_balance = true;
                if (obj.getInt("balance_sheet") == 1)
                    User.balance_sheet = true;
                if (obj.getInt("financial_statement") == 1)
                    User.financial_statement = true;
                if (obj.getInt("database_maintanance") == 1)
                    User.database_maintanance = true;

                Platform.runLater(() -> {
                    try {
                        this.login_btn.getScene().getWindow().hide();
                        Parent root;
                        root = FXMLLoader.load(getClass().getResource(MetaData.viewPath + "home1.fxml"));
                        Scene scene = new Scene(root);
                        scene.getStylesheets().add("/style.css");
                        Stage stage = new Stage();
                        scene.setRoot(root);
                        stage.setResizable(true);
                        stage.setTitle("Home");
                        stage.setScene(scene);
                        stage.showAndWait();
                    } catch (IOException ex) {
                        Logger.getLogger(loginController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                });

            } catch (Exception ex) {
                Platform.runLater(() -> {
                    Msg.showError("Username or password is incorrect");
                });
            } finally {
                login_btn.setDisable(false);
                Platform.runLater(() -> {
                    login_btn.setText("Login");

                });

            }
        });
        t.start();

    } catch (Exception e) {
        Msg.showError("Sorry. There is an error. Please try again");
    }
}