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.nmrfx.processor.gui.MainApp.java

@Override
public void start(Stage stage) throws Exception {
    stages.add(stage);/*from   w w w.ja v  a 2s.co m*/
    mainApp = this;
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/NMRScene.fxml"));
    Platform.setImplicitExit(true);
    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/Styles.css");
    hostServices = getHostServices();

    stage.setTitle(appName + " " + getVersion());
    stage.setScene(scene);
    stage.show();

    if (mainMenuBar == null) {
        mainMenuBar = makeMenuBar(appName);
    }
    Parameters parameters = getParameters();
    System.out.println(parameters.getRaw());

    interpreter.exec(
            "from pyproc import *\ninitLocal()\nfrom gscript import *\nnw=NMRFxWindowScripting()\nfrom dscript import *");
    interpreter.set("argv", parameters.getRaw());
    interpreter.exec("parseArgs(argv)");
    Dataset.addObserver(this);
}

From source file:memoryaid.SetReminderController.java

@FXML
private void handleBackButtonAction(ActionEvent event) throws IOException {
    System.out.println("You clicked back/cancel!");
    Parent setReminder = FXMLLoader.load(getClass().getResource("Caregiver.fxml"));
    Scene set_reminder_back_scene = new Scene(setReminder);
    Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
    app_stage.hide();//from  www  .  j  a va  2  s.c o  m
    app_stage.setScene(set_reminder_back_scene);
    app_stage.show();
}

From source file:com.jcwhatever.resourcepackermc.Main.java

@Override
public void start(Stage stage) throws Exception {
    stage.setMinWidth(600);/*w  w  w .j a v a  2s.  co  m*/
    stage.setMinWidth(400);
    Parent root = FXMLLoader.load(getClass().getResource("/com/jcwhatever/resourcepackermc/gui/Main.fxml"));
    stage.setTitle("ResourcePackerMC 0.2 beta");
    stage.setScene(new Scene(root, 600, 400));
    stage.show();
}

From source file:memoryaid.SetReminderController.java

@FXML
private void handleDeleteButtonAction(ActionEvent event) throws SQLException, IOException {
    System.out.println("Delete button selected");

    ReminderModel selectedItem = (ReminderModel) reminderTable.getSelectionModel().getSelectedItem();
    System.out.println(selectedItem);
    String RIdToDelete = selectedItem.getReminderId();

    Statement stmt = null;//from w  ww.  j a  v a  2s .  co m
    DbConnection db = new DbConnection();
    Connection conn = db.connect();
    stmt = conn.createStatement();
    String sql1 = "DELETE FROM Reminders " + "WHERE RId = '" + RIdToDelete + "'";
    stmt.executeUpdate(sql1);

    String sql2 = "DELETE FROM ReminderDetails " + "WHERE RId = '" + RIdToDelete + "'";
    stmt.executeUpdate(sql2);
    System.out.println("Delete Successfull");
    Parent setReminder = FXMLLoader.load(getClass().getResource("SetReminder.fxml"));
    Scene set_reminder_refresh_scene = new Scene(setReminder);
    Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
    app_stage.hide();
    app_stage.setScene(set_reminder_refresh_scene);
    app_stage.show();
}

From source file:analyzer.code.FXMLAnalyzerController.java

@FXML
private void aboutProgrammMunuItem() throws FileNotFoundException, IOException {
    Parent root2 = (Parent) FXMLLoader.load(getClass().getResource("FXMLAboutProgramm.fxml"));
    Scene scene = new Scene(root2);
    Stage stage = new Stage();
    stage.setScene(scene);/*ww w. j  a v a 2 s.com*/
    stage.setTitle(" ");
    stage.show();
}

From source file:com.SignalDiagram.FXMLDocumentController.java

@FXML
private void showAbout(ActionEvent event) {
    Stage stage = new Stage();
    Parent root;//from   w w w .  jav  a 2s. co  m
    try {
        root = FXMLLoader.load(getClass().getResource("FXMLAbout.fxml"));

        stage.setScene(new Scene(root));
        stage.setTitle("About");
        stage.initStyle(StageStyle.UTILITY);
        stage.initModality(Modality.APPLICATION_MODAL);
        // stage.initOwner(((Node) event.getSource()).getScene().getWindow());
        stage.setResizable(false);
        stage.show();

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

From source file:ui.main.MainViewController.java

@FXML
public void handleEditMyAccountMenuCall(ActionEvent event) {
    try {//  w  w w .  jav a 2s . c o m
        //default configuration and initialization of the form
        Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui/account/AccountView.fxml"));

        Scene scene = new Scene(root);

        Stage stage = new Stage();

        stage.setScene(scene);
        stage.show();

        stage.setResizable(false);
        stage.setTitle("IMP");
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ui.main.MainViewController.java

@FXML
public void handleContactMenuCall(ActionEvent event) {
    //this method displays the contact view
    try {//from w  ww  .j  a  v  a2 s .  c o m
        //default configuration and initialization of the form
        Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui/contacts/ContactsView.fxml"));

        Scene scene = new Scene(root);

        Stage stage = new Stage();

        stage.setScene(scene);
        stage.show();

        stage.setResizable(false);
        stage.setTitle("IMP : Contacts");
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.mycompany.pfinanzaspersonales.BuscadorController.java

@FXML
private void btnBuscar(ActionEvent event) throws IOException {

    String desde_t = "", hasta_t = "";

    if (input_desde.getValue() != null) {
        desde_t = input_desde.getValue().toString();
    }/*from  www  .  ja  v  a2s  .  c o m*/

    if (input_hasta.getValue() != null) {
        hasta_t = input_hasta.getValue().toString();
    }

    final String desde = desde_t;
    final String hasta = hasta_t;

    final Task<Void> tarea = new Task<Void>() {
        @Override
        protected Void call() throws Exception {

            HttpResponse response;
            List<NameValuePair> parametros = new ArrayList<NameValuePair>();

            parametros.add(new BasicNameValuePair("tipo", cbb_tipo.getValue().toString()));
            parametros.add(new BasicNameValuePair("pago", cbb_pago.getValue().toString()));
            parametros.add(new BasicNameValuePair("desde", desde));
            parametros.add(new BasicNameValuePair("hasta", hasta));

            System.out.println(desde);
            response = JSON.request(Config.URL + "usuarios/buscar.json", parametros);

            JSONObject jObject = JSON.JSON(response);
            tabla_json = new ArrayList<TablaBuscar>();

            try {

                editar.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("editar"));
                eliminar.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("eliminar"));
                fecha.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("fecha"));
                categoria.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("categoria"));
                tpago.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("pago"));
                tmonto.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("monto"));
                ttipo.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("tipo"));

                tabla_json = new ArrayList<TablaBuscar>();

                if (!jObject.get("data").equals(null)) {
                    JSONArray jsonArr = jObject.getJSONArray("data");
                    for (int i = 0; i < jsonArr.length(); i++) {
                        JSONObject data_json = jsonArr.getJSONObject(i);
                        tabla_json.add(new TablaBuscar(data_json.get("idgastos").toString(),
                                data_json.get("idgastos").toString(), data_json.get("idgastos").toString(),
                                data_json.get("monto").toString(), data_json.get("fecha").toString(),
                                data_json.get("nom_mediopago").toString(),
                                data_json.get("categoria").toString(), data_json.get("tipo").toString()));
                    }
                }
                tabla_buscador.setItems(FXCollections.observableArrayList(tabla_json));

            } catch (Exception e) {
                e.printStackTrace();
            }

            return null;
        }

        @Override
        protected void succeeded() {
            super.succeeded();

            eliminar.setCellFactory(new Callback<TableColumn<String, String>, TableCell<String, String>>() {
                @Override
                public TableCell<String, String> call(TableColumn<String, String> p) {

                    return new TableCell<String, String>() {
                        @Override
                        public void updateItem(String item, boolean empty) {

                            super.updateItem(item, empty);

                            if (!isEmpty() && !empty) {

                                final VBox vbox = new VBox(5);
                                Image image = new Image(getClass().getResourceAsStream("/Imagenes/delete.png"));
                                final Button boton = new Button("", new ImageView(image));
                                boton.setOnAction(new EventHandler<ActionEvent>() {
                                    @Override
                                    public void handle(ActionEvent event) {

                                        Action response = Dialogs.create().title("Eliminar Gasto")
                                                .message("Ests seguro que desaeas eliminar el gasto?")
                                                .showConfirm();

                                        if (response == Dialog.ACTION_YES) {

                                            TablaBuscar tabla = tabla_json.get(getTableRow().getIndex());

                                            List<NameValuePair> parametros = new ArrayList<NameValuePair>();

                                            String url = "";
                                            if (tabla.getTipo() == "Gastos") {
                                                parametros
                                                        .add(new BasicNameValuePair("idgastos", tabla.getId()));
                                                url = Config.URL + "gastos/eliminar.json";
                                            } else {
                                                parametros.add(
                                                        new BasicNameValuePair("idingresos", tabla.getId()));
                                                url = Config.URL + "ingresos/eliminar.json";
                                            }

                                            HttpResponse responseJSON = JSON.request(url, parametros);
                                            JSONObject jObject = JSON.JSON(responseJSON);
                                            int code = Integer.parseInt(jObject.get("code").toString());

                                            if (code == 201) {
                                                int selectdIndex = getTableRow().getIndex();
                                                tabla_json.remove(selectdIndex);
                                                tabla_buscador.getItems().remove(selectdIndex);
                                            } else {
                                                Dialogs.create().title("Error sincronizacin").message(
                                                        "Hubo un error al intentar eliminar . ERROR: 301")
                                                        .showInformation();
                                            }

                                        }

                                    }
                                });

                                vbox.getChildren().add(boton);
                                setGraphic(vbox);
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });

            editar.setCellFactory(new Callback<TableColumn<String, String>, TableCell<String, String>>() {
                @Override
                public TableCell<String, String> call(TableColumn<String, String> p) {

                    return new TableCell<String, String>() {
                        @Override
                        public void updateItem(String item, boolean empty) {

                            super.updateItem(item, empty);

                            if (!isEmpty() && !empty) {

                                final VBox vbox = new VBox(5);
                                Image image = new Image(getClass().getResourceAsStream("/Imagenes/edit.png"));
                                final Button boton = new Button("", new ImageView(image));
                                boton.setOnAction(new EventHandler<ActionEvent>() {
                                    @Override
                                    public void handle(ActionEvent event) {

                                        TablaBuscar tabla = tabla_json.get(getTableRow().getIndex());

                                        Parent parent = null;
                                        if (tabla.getTipo() == "Gastos") {
                                            AgregarGastos AG = AgregarGastos.getInstance();

                                            AG.setID(tabla.getId());
                                            AG.setMonto(tabla.getMonto());
                                            AG.setCategoria(tabla.getCategoria());
                                            AG.setPago(tabla.getPago());
                                            AG.setActualizacion(true);

                                            try {
                                                parent = FXMLLoader.load(this.getClass()
                                                        .getResource("/fxml/AgregarGastos.fxml"));
                                            } catch (IOException ex) {
                                                Logger.getLogger(FXMLController.class.getName())
                                                        .log(Level.SEVERE, null, ex);
                                            }
                                        } else {
                                            AgregarIngresos AI = AgregarIngresos.getInstance();

                                            AI.setID(tabla.getId());
                                            AI.setMonto(tabla.getMonto());
                                            AI.setCategoria(tabla.getCategoria());
                                            AI.setPago(tabla.getPago());
                                            AI.setActualizar(true);

                                            try {
                                                parent = FXMLLoader.load(this.getClass()
                                                        .getResource("/fxml/AgregarIngresos.fxml"));
                                            } catch (IOException ex) {
                                                Logger.getLogger(FXMLController.class.getName())
                                                        .log(Level.SEVERE, null, ex);
                                            }
                                        }

                                        Stage stage = new Stage();
                                        Scene scene = new Scene(parent);
                                        stage.setScene(scene);
                                        stage.show();

                                    }
                                });

                                vbox.getChildren().add(boton);
                                setGraphic(vbox);
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });

        }
    };
    new Thread(tarea).start();
}

From source file:ui.main.MainViewController.java

@FXML
public void handleAboutMenuCall(ActionEvent event) {
    //this method displays the about
    try {// w  w  w.  j a v a2s . c  o  m
        //default configuration and initialization of the form
        Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui/about/AboutView.fxml"));

        Scene scene = new Scene(root);

        Stage stage = new Stage();

        stage.setScene(scene);
        stage.show();

        stage.setResizable(false);
        stage.setTitle("About");
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}