Example usage for javafx.scene.control Button setOnAction

List of usage examples for javafx.scene.control Button setOnAction

Introduction

In this page you can find the example usage for javafx.scene.control Button setOnAction.

Prototype

public final void setOnAction(EventHandler<ActionEvent> value) 

Source Link

Usage

From source file:FeeBooster.java

@Override
public void start(Stage primaryStage) throws Exception {

    // Setup the stage
    stage = primaryStage;//from   w  w  w  .  ja  va  2  s  .  c o  m
    primaryStage.setTitle("Bitcoin Transaction Fee Booster");

    // Setup intro gridpane
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    // Intro Text
    Text scenetitle = new Text(
            "Welcome to the fee booster. \n\nWhat type of transaction would you like to boost the fee of?");
    grid.add(scenetitle, 0, 0, 2, 3);

    // radio button selections
    VBox boostRadioVbox = new VBox();
    ToggleGroup boostTypeGroup = new ToggleGroup();
    RadioButton rbfRadio = new RadioButton("A transaction you sent");
    rbfRadio.setToggleGroup(boostTypeGroup);
    boostRadioVbox.getChildren().add(rbfRadio);
    RadioButton cpfpRadio = new RadioButton("A transaction you received");
    cpfpRadio.setToggleGroup(boostTypeGroup);
    rbfRadio.setSelected(true);
    boostRadioVbox.getChildren().add(cpfpRadio);
    grid.add(boostRadioVbox, 0, 3);

    // Instructions Text
    Text instruct = new Text("Please enter the raw hex or transaction id of your transaction below:");
    grid.add(instruct, 0, 4);

    // Textbox for hex of transaction
    TextArea txHexTxt = new TextArea();
    txHexTxt.setWrapText(true);
    grid.add(txHexTxt, 0, 5, 5, 1);

    // Next Button
    Button nextBtn = new Button("Next");
    nextBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {

            // Create Transaction
            Transaction tx = new Transaction();

            // Check if txid
            boolean isTxid = txHexTxt.getText().length() == 64 && txHexTxt.getText().matches("[0-9A-Fa-f]+");
            if (isTxid)
                tx.setHash(txHexTxt.getText());

            // Determine which page to go to
            if (Transaction.deserializeStr(txHexTxt.getText(), tx) || isTxid) {

                // Get the fee
                JSONObject apiResult = Utils
                        .getFromAnAPI("https://api.blockcypher.com/v1/btc/main/txs/" + tx.getHash(), "GET");

                // Get the fee
                tx.setFee(apiResult.getInt("fees"));
                tx.setTotalAmtPre(tx.getFee() + tx.getOutAmt());

                // Get info if txid
                if (isTxid) {

                }

                Scene scene = null;
                if (rbfRadio.isSelected())
                    if (sceneCursor == scenes.size() - 1 || !rbf) {
                        scene = new Scene(rbfGrid(tx), 900, 500);
                        if (!rbf) {
                            scenes.clear();
                            scenes.add(stage.getScene());
                        }
                        rbf = true;
                    }
                if (cpfpRadio.isSelected())
                    if (sceneCursor == scenes.size() - 1 || rbf) {
                        scene = new Scene(cpfpGrid(tx), 900, 500);
                        if (rbf) {
                            scenes.clear();
                            scenes.add(stage.getScene());
                        }
                        rbf = false;
                    }

                if (sceneCursor != scenes.size() - 1)
                    scene = scenes.get(sceneCursor + 1);
                else
                    scenes.add(scene);
                sceneCursor++;
                stage.setScene(scene);
            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR, "Please enter a valid transaction");
                alert.showAndWait();
            }
        }
    });
    HBox btnHbox = new HBox(10);
    btnHbox.getChildren().add(nextBtn);

    // Cancel Button
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setOnAction(cancelEvent);
    btnHbox.getChildren().add(cancelBtn);
    grid.add(btnHbox, 2, 7);

    // Display everything
    Scene scene = new Scene(grid, 900, 500);
    scenes.add(scene);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:photobooth.views.ExplorerPane.java

private void init(String dir, int offset, int limit, int directoryLevel) {

    this.getChildren().removeAll(this.getChildren());
    this.dir = dir;
    this.offset = offset;
    this.limit = limit;
    this.directoryLevel = directoryLevel;

    try {/*from  ww w. ja v  a 2s. c  o  m*/
        addXButton();
    } catch (IOException ex) {
        Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (directoryLevel > 0) {
        try {
            addUpButton();
        } catch (IOException ex) {
            Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    addLabel();

    TilePane tile = new TilePane();
    tile.setHgap(12);
    tile.setVgap(12);

    File folder = new File(dir);
    File[] listOfDirs = folder.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.isDirectory();
        }
    });
    File[] allFileAndDiresctoies = new File[0];
    if (listOfDirs != null) {
        Arrays.sort(listOfDirs);

        File[] listOfImages = folder.listFiles(new FileFilter() {

            @Override
            public boolean accept(File file) {
                String ext = FilenameUtils.getExtension(file.getAbsolutePath());
                return ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("png");
            }
        });
        Arrays.sort(listOfImages);
        allFileAndDiresctoies = new File[listOfDirs.length + listOfImages.length];
        System.arraycopy(listOfDirs, 0, allFileAndDiresctoies, 0, listOfDirs.length);
        System.arraycopy(listOfImages, 0, allFileAndDiresctoies, listOfDirs.length, listOfImages.length);

        File[] subArray = new File[limit];
        int countToCopy = limit;
        if (offset + limit > allFileAndDiresctoies.length) {
            countToCopy -= offset + limit - allFileAndDiresctoies.length;
        }
        System.arraycopy(allFileAndDiresctoies, offset, subArray, 0, countToCopy);

        for (final File file : subArray) {
            if (file == null) {
                break;
            }
            if (file.isFile()) {
                tile.getChildren().add(createImageView(file));
            } else {
                Button button = new Button(file.getName());
                button.setMaxSize(100, 100);
                button.setMinSize(100, 100);
                button.setWrapText(true);
                button.getStyleClass().add("folderButton");

                button.setOnAction(new EventHandler<ActionEvent>() {
                    @Override
                    public void handle(ActionEvent event) {

                        Global.getInstance().setSceneRoot(LoadingPane.getInstance());

                        Platform.runLater(() -> {
                            new Thread(new Runnable() {

                                @Override
                                public void run() {
                                    ExplorerPane.getInstance().setDir(file.getAbsolutePath(), 0, limit,
                                            directoryLevel + 1);
                                    Global.getInstance().setSceneRoot(ExplorerPane.getInstance());
                                }
                            }).start();
                        });

                    }
                });
                tile.getChildren().add(button);

            }
        }
    }
    this.getChildren().add(tile);
    tile.setMinWidth(670);
    tile.setMaxWidth(670);
    tile.setLayoutX(65);
    tile.setLayoutY(70);
    tile.setMaxHeight(390);

    if (allFileAndDiresctoies.length > offset + limit) {
        try {
            addNextButton();
        } catch (IOException ex) {
            Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (offset > 0) {
        try {
            addPrevButton();
        } catch (IOException ex) {
            Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:gov.va.isaac.sync.view.SyncView.java

private void initGui() {
    root_ = new BorderPane();
    root_.setPrefWidth(550);//w  ww . j  a v a  2 s . c  om

    VBox titleBox = new VBox();

    Label title = new Label("Datastore Synchronization");
    title.getStyleClass().add("titleLabel");
    title.setAlignment(Pos.CENTER);
    title.setMaxWidth(Double.MAX_VALUE);
    title.setPadding(new Insets(10));
    titleBox.getChildren().add(title);
    titleBox.getStyleClass().add("headerBackground");

    url_ = AppContext.getAppConfiguration().getCurrentChangeSetUrl();
    String urlType = AppContext.getAppConfiguration().getChangeSetUrlTypeName();

    String syncUsername = ExtendedAppContext.getCurrentlyLoggedInUserProfile().getSyncUsername();
    if (StringUtils.isBlank(syncUsername)) {
        syncUsername = ExtendedAppContext.getCurrentlyLoggedInUser();
    }

    url_ = syncService_.substituteURL(url_, syncUsername);

    Label info = new CopyableLabel("Sync using " + urlType + ": " + url_);
    info.setTooltip(new Tooltip(url_));

    titleBox.getChildren().add(info);

    titleBox.setPadding(new Insets(5, 5, 5, 5));
    root_.setTop(titleBox);

    VBox centerContent = new VBox();
    centerContent.setFillWidth(true);
    centerContent.setPrefWidth(Double.MAX_VALUE);
    centerContent.setPadding(new Insets(10));
    centerContent.getStyleClass().add("itemBorder");
    centerContent.setSpacing(10.0);

    centerContent.getChildren().add(new Label("Status:"));

    summary_ = new TextArea();
    summary_.setWrapText(true);
    summary_.setEditable(false);
    summary_.setMaxWidth(Double.MAX_VALUE);
    summary_.setMaxHeight(Double.MAX_VALUE);
    summary_.setPrefHeight(150.0);

    centerContent.getChildren().add(summary_);
    VBox.setVgrow(summary_, Priority.ALWAYS);

    pb_ = new ProgressBar(0.0);
    pb_.setPrefHeight(20);
    pb_.setMaxWidth(Double.MAX_VALUE);

    centerContent.getChildren().add(pb_);

    root_.setCenter(centerContent);

    //Bottom buttons
    HBox buttons = new HBox();
    buttons.setMaxWidth(Double.MAX_VALUE);
    buttons.setAlignment(Pos.CENTER);
    buttons.setPadding(new Insets(5));
    buttons.setSpacing(30);

    Button cancel = new Button("Close");
    cancel.setOnAction((action) -> {
        if (running_.get()) {
            addLine("Cancelling...");
            cancel.setDisable(true);
            cancelRequested_ = true;
        } else {
            cancel.getScene().getWindow().hide();
            root_ = null;
        }
    });
    buttons.getChildren().add(cancel);

    Button action = new Button("Synchronize");
    action.disableProperty().bind(running_);
    action.setOnAction((theAction) -> {
        summary_.setText("");
        pb_.setProgress(-1.0);
        running_.set(true);
        Utility.execute(() -> sync());
    });
    buttons.getChildren().add(action);

    cancel.minWidthProperty().bind(action.widthProperty());

    running_.addListener(change -> {
        if (running_.get()) {
            cancel.setText("Cancel");
        } else {
            cancel.setText("Close");
        }
        cancel.setDisable(false);
    });

    root_.setBottom(buttons);
}

From source file:AudioPlayer3.java

private Node createControlPanel() {
    final HBox hbox = new HBox();
    hbox.setAlignment(Pos.CENTER);// w  w w.ja  v a2  s.c o  m
    hbox.setFillHeight(false);

    final Button playPauseButton = createPlayPauseButton();

    final Button seekStartButton = new Button();
    seekStartButton.setId("seekStartButton");
    seekStartButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            seekAndUpdatePosition(Duration.ZERO);
        }
    });

    final Button seekEndButton = new Button();
    seekEndButton.setId("seekEndButton");
    seekEndButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            final MediaPlayer mediaPlayer = songModel.getMediaPlayer();
            final Duration totalDuration = mediaPlayer.getTotalDuration();
            final Duration oneSecond = Duration.seconds(1);
            seekAndUpdatePosition(totalDuration.subtract(oneSecond));
        }
    });

    hbox.getChildren().addAll(seekStartButton, playPauseButton, seekEndButton);
    return hbox;
}

From source file:cz.lbenda.gui.tableView.FilterMenuItem.java

private void prepareOkCancelBar() {
    Button okButton = new Button(msgOK);
    okButton.setDefaultButton(true);//from   ww w .j  a va  2  s .  co m
    Button cancelButton = new Button(msgCancel);
    cancelButton.setCancelButton(true);
    okCancelBar.getChildren().addAll(okButton, cancelButton);

    //noinspection unchecked
    final StringConverter converter = filterableTableView.stringConverter(tableColumn);
    okButton.setOnAction(event -> {
        if (filter != null) {
            filterableTableView.filters().remove(filter);
        }
        if (!isFilter()) {
            tableColumn.removeLeftIndicator(filterIndicator);
        } else {
            tableColumn.addLeftIndicator(filterIndicator);
            //noinspection unchecked
            filter = row -> {
                //noinspection unchecked
                Object value = filterableTableView.valueForColumn(row, tableColumn);
                String text;
                if (value == null) {
                    text = "";
                } else { //noinspection unchecked
                    text = converter.toString(value);
                }
                return chosenItemNames.contains(text);
            };
            //noinspection unchecked
            filterableTableView.filters().add(filter);
        }
    });
}

From source file:photobooth.views.EmailPane.java

private void addXButton() {
    Button button = new Button();
    try {/*  www .ja  v a  2  s  . c  o  m*/
        button.setGraphic(
                new ImageView(new Image(getClass().getResource("/photobooth/images/exit.png").openStream())));
    } catch (IOException ex) {
        Logger.getLogger(EmailPane.class.getName()).log(Level.SEVERE, null, ex);
    }
    button.setStyle("-fx-background-color: transparent;");
    button.setLayoutX(730);
    button.setLayoutY(10);
    button.setMaxSize(50, 50);
    button.setMinSize(50, 50);
    button.getStyleClass().add("blueButton");
    this.getChildren().add(button);
    button.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            t.cancel();
            t.purge();
            Global.getInstance().setSceneRoot(HomePane.getInstance());
        }
    });
}

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 w w  w  . j av a 2 s .  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:AudioPlayer3.java

private Button createPlayPauseButton() {
    URL url = getClass().getResource("resources/pause.png");
    pauseImg = new Image(url.toString());

    url = getClass().getResource("resources/play.png");
    playImg = new Image(url.toString());

    playPauseIcon = new ImageView(playImg);

    final Button playPauseButton = new Button(null, playPauseIcon);
    playPauseButton.setId("playPauseButton");
    playPauseButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override/*w  ww  . ja  v  a  2  s .  c  o  m*/
        public void handle(ActionEvent arg0) {
            final MediaPlayer mediaPlayer = songModel.getMediaPlayer();
            if (mediaPlayer.getStatus() == MediaPlayer.Status.PLAYING) {
                mediaPlayer.pause();
            } else {
                mediaPlayer.play();
            }
        }
    });
    return playPauseButton;
}

From source file:photobooth.views.ExplorerPane.java

private void addUpButton() throws IOException {
    Button button = new Button();
    button.setGraphic(/*  w w  w  .ja v  a2 s . c om*/
            new ImageView(new Image(getClass().getResource("/photobooth/images/up.png").openStream())));
    button.setStyle("-fx-background-color: transparent;");
    button.setMaxSize(50, 50);
    button.setMinSize(50, 50);
    button.setLayoutX(120);
    button.setLayoutY(10);
    this.getChildren().add(button);
    button.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            Global.getInstance().setSceneRoot(LoadingPane.getInstance());

            Platform.runLater(() -> {
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        ExplorerPane.getInstance().setDir(new File(dir).getParentFile().getAbsolutePath(), 0,
                                limit, directoryLevel - 1);
                        Global.getInstance().setSceneRoot(ExplorerPane.getInstance());
                    }
                }).start();
            });

        }
    });

}

From source file:statos2_0.StatOS2_0.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");

    GridPane root = new GridPane();
    Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    root.setAlignment(Pos.CENTER);/*from w  ww.jav a2 s.co  m*/
    root.setHgap(10);
    root.setVgap(10);
    root.setPadding(new Insets(25, 25, 25, 25));

    Text scenetitle = new Text("");

    root.add(scenetitle, 0, 0, 2, 1);
    scenetitle.setId("welcome-text");
    Label userName = new Label(":");
    //userName.setId("label");
    root.add(userName, 0, 1);

    TextField userTextField = new TextField();
    root.add(userTextField, 1, 1);

    Label pw = new Label(":");
    root.add(pw, 0, 2);

    PasswordField pwBox = new PasswordField();
    root.add(pwBox, 1, 2);
    ComboBox store = new ComboBox();
    store.setItems(GetByTag());
    root.add(store, 1, 3);

    Button btn = new Button("");
    //btn.setPrefSize(100, 20);
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);

    root.add(hbBtn, 1, 4);

    Button btn2 = new Button("");
    //btn2.setPrefSize(100, 20);
    HBox hbBtn2 = new HBox(10);
    hbBtn2.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn2.getChildren().add(btn2);
    root.add(hbBtn2, 1, 5);

    final Text actiontarget = new Text();
    root.add(actiontarget, 1, 6);

    btn2.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            System.exit(0);
        }
    });

    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            if (userTextField.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (pwBox.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (store.getSelectionModel().getSelectedIndex() < 0) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else {
                try {
                    String[] resu = checkpas(userTextField.getText(), pwBox.getText());
                    if (resu[0].equals("-1")) {
                        Alert alert = new Alert(Alert.AlertType.ERROR);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("   !");
                        alert.showAndWait();
                    } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) {
                        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("     !"
                                + "\n       -  ");
                        Optional<ButtonType> result = alert.showAndWait();
                        if (result.get() == ButtonType.OK) {
                            // ... user chose OK
                            idstore = store.getSelectionModel().getSelectedIndex() + 1;
                            updsel(idstore, Integer.parseInt(resu[0]));
                            MainA ma = new MainA();
                            ma.m = (idstore);
                            ma.MT = "m" + idstore;
                            ma.selid = Integer.parseInt(resu[0]);
                            ma.nameseller = resu[1];
                            ma.storename = store.getSelectionModel().getSelectedItem().toString();
                            ma.start(primaryStage);
                        } else {
                            // ... user chose CANCEL or closed the dialog
                        }

                    } else {
                        // 

                        idstore = store.getSelectionModel().getSelectedIndex() + 1;
                        updsel(idstore, Integer.parseInt(resu[0]));
                        MainA ma = new MainA();
                        ma.m = (idstore);
                        ma.MT = "m" + idstore;
                        ma.selid = Integer.parseInt(resu[0]);
                        ma.nameseller = resu[1];
                        ma.storename = store.getSelectionModel().getSelectedItem().toString();

                        ma.start(primaryStage);

                    }

                } catch (NoSuchAlgorithmException ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            /**
             * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){
             * actiontarget.setId("acttrue");
             * actiontarget.setText(" !");
             * MainA ma = new MainA();
             * ma.m=1;
             * try {
             * ma.m=1;
             * ma.MT="m1";
             * ma.start(primaryStage);
             * } catch (Exception ex) {
             * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
             * }
             * }else{
             * actiontarget.setId("actfalse");
             * actiontarget.setText(" !");
             * } **/

        }
    });
    //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    //sSize.getHeight();
    Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight());

    primaryStage.setScene(scene);
    scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm());
    primaryStage.show();
}