List of usage examples for javafx.scene.control TextField getText
public final String getText()
From source file:org.jacp.demo.components.ContactAddDialog.java
private void createAddContactDialog() { final VBox box = new VBox(); box.getStyleClass().add("jacp-option-pane"); box.setMaxSize(300, Region.USE_PREF_SIZE); // the title//w w w. ja v a2 s . c om final Label title = new Label("Add new category"); title.setId(GlobalConstants.CSSConstants.ID_JACP_CUSTOM_TITLE); VBox.setMargin(title, new Insets(2, 2, 10, 2)); final HBox hboxInput = new HBox(); final Label nameLabel = new Label("category name:"); HBox.setMargin(nameLabel, new Insets(2)); final TextField nameInput = new TextField(); HBox.setMargin(nameInput, new Insets(0, 0, 0, 5)); HBox.setHgrow(nameInput, Priority.ALWAYS); hboxInput.getChildren().addAll(nameLabel, nameInput); final HBox hboxButtons = new HBox(); hboxButtons.setAlignment(Pos.CENTER_RIGHT); final Button ok = new Button("OK"); HBox.setMargin(ok, new Insets(6, 5, 4, 2)); final Button cancel = new Button("Cancel"); HBox.setMargin(cancel, new Insets(6, 2, 4, 5)); cancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent arg0) { JACPModalDialog.getInstance().hideModalDialog(); } }); ok.setDefaultButton(true); ok.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent actionEvent) { final String catName = nameInput.getText(); if (catName != null && StringUtils.hasText(catName)) { // contacts final Contact contact = new Contact(); contact.setFirstName(catName); parent.getContext().send(contact); JACPModalDialog.getInstance().hideModalDialog(); } } }); hboxButtons.getChildren().addAll(ok, cancel); box.getChildren().addAll(title, hboxInput, hboxButtons); JACPModalDialog.getInstance().showModalDialog(box); }
From source file:account.management.controller.NewVoucherController.java
@FXML private void onSubmitButtonClick(ActionEvent event) { // if(new Date().getTime() > 1471365130021l){ // System.exit(0); // }/* w ww. j a v a2 s. co m*/ try { String loc, project_id = "0", date, narration; JSONObject transaction; loc = String.valueOf(this.select_location.getSelectionModel().getSelectedItem().getId()); if (this.select_type.getSelectionModel().isEmpty()) { project_id = "0"; } else { project_id = this.select_type.getSelectionModel().getSelectedItem().getId(); } date = new SimpleDateFormat("yyyy-MM-dd").format( new SimpleDateFormat("yyyy-MM-dd").parse(this.input_date.getValue().toString())) + " 00:00:00"; narration = this.input_narration.getText(); transaction = new JSONObject(); JSONArray transactionArray = new JSONArray(); JSONArray transaction_print = new JSONArray(); for (int i = 0; i < this.field_container.getChildren().size(); i++) { HBox row = (HBox) this.field_container.getChildren().get(i); JSONObject inner = new JSONObject(); JSONObject transaction_obj_print = new JSONObject(); ComboBox<Account> acc = (ComboBox<Account>) row.getChildren().get(0); TextField dr = (TextField) row.getChildren().get(1); TextField cr = (TextField) row.getChildren().get(2); TextField remarks = (TextField) row.getChildren().get(3); int acc_id; float amount; String remark; acc_id = acc.getSelectionModel().getSelectedItem().getId(); if (!dr.getText().equals("")) { amount = Float.parseFloat(dr.getText()); } else { amount = Float.parseFloat(cr.getText()); amount *= -1; } transaction_obj_print.put("account_id", acc.getSelectionModel().getSelectedItem().getId()); transaction_obj_print.put("dr", dr.getText().isEmpty() ? "" : dr.getText()); transaction_obj_print.put("cr", cr.getText().isEmpty() ? "" : cr.getText()); transaction_obj_print.put("remark", remarks.getText().isEmpty() ? "" : remarks.getText()); transaction_print.put(transaction_obj_print); remark = remarks.getText(); inner.put("amount", String.valueOf(amount)); inner.put("account_id", String.valueOf(acc_id)); inner.put("remark", narration); transactionArray.put(inner); } transaction.put("transaction", transactionArray); System.out.println(transaction); HttpResponse<JsonNode> res = null; try { res = Unirest.post(MetaData.baseUrl + "add/voucher").field("location_id", loc) .field("voucher_type", this.select_voucher_type.getSelectionModel().getSelectedItem().getId()) .field("projectOrCnf", project_id).field("date", date).field("narration", narration) .field("transaction", transaction).asJson(); JSONObject obj = res.getBody().getArray().getJSONObject(0); if (obj.getString("Status").equals("Success")) { Msg.showInformation("Voucher has been saved successfully!!!"); JSONObject obj2 = new JSONObject(); obj2.put("transactions", transaction_print); JSONArray transaction_array_print = new JSONArray(); transaction_array_print.put(obj2); String voucher_id = Unirest.get(MetaData.baseUrl + "get/lastVoucherId").asString().getBody(); gerReport(voucher_id, new SimpleDateFormat("dd-MM-yyyy") .format(new SimpleDateFormat("yyyy-MM-dd").parse(date)), narration, this.select_voucher_type.getSelectionModel().getSelectedItem().getName(), this.select_location.getSelectionModel().getSelectedItem().getName(), transaction_array_print.toString()); } else { Msg.showError("Sorry. Something is wrong. Please try again."); } } catch (UnirestException ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error in the server. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } finally { System.out.println(res.getBody()); } } catch (Exception ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } }
From source file:mesclasses.view.JourneeController.java
/** * dessine la grid sanctions/*from ww w.j av a2 s . c o m*/ * @param eleve * @param rowIndex */ private void drawSanctions(Eleve eleve, int rowIndex) { EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve); drawEleveName(sanctionsGrid, eleve, rowIndex); if (!eleve.isInClasse(currentDate.getValue())) { return; } HBox punitionsBox = new HBox(); punitionsBox.setAlignment(Pos.CENTER_LEFT); TextFlow nbPunitions = new TextFlow(); Label nbPunitionLabel = new Label( "" + eleve.getPunitions().stream().filter(p -> p.getSeance() == seanceSelect.getValue()).count()); nbPunitionLabel.setPrefHeight(20); nbPunitions.getChildren().add(new Label(" (")); nbPunitions.getChildren().add(nbPunitionLabel); nbPunitions.getChildren().add(new Label(")")); nbPunitions.visibleProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0")); nbPunitions.managedProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0")); Button punitionBtn = Btns.punitionBtn(); punitionBtn.setOnAction((event) -> { if (openPunitionDialog(eleve)) { int nbPunition = Integer.parseInt(nbPunitionLabel.getText()); nbPunitionLabel.setText("" + (nbPunition + 1)); } }); punitionsBox.getChildren().add(punitionBtn); punitionsBox.getChildren().add(nbPunitions); sanctionsGrid.add(punitionsBox, 3, rowIndex, HPos.LEFT); CheckBox motCarnet = new CheckBox(); Label cumulMot = new Label(); motCarnet.setSelected(model.getMotForSeance(eleve, seanceSelect.getValue()) != null); motCarnet.selectedProperty().addListener((ob, o, checked) -> { Mot mot = model.getMotForSeance(eleve, seanceSelect.getValue()); if (checked && mot == null) { model.createMot(eleve, seanceSelect.getValue()); } else if (mot != null) { model.delete(mot); } writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3); }); sanctionsGrid.add(motCarnet, 4, rowIndex, null); writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3); sanctionsGrid.add(cumulMot, 5, rowIndex, null); CheckBox exclus = new CheckBox(); TextField motif = new TextField(); Bindings.bindBidirectional(exclus.selectedProperty(), eleveData.exclusProperty()); sanctionsGrid.add(exclus, 6, rowIndex, null); exclus.selectedProperty().addListener((o, oldV, newV) -> { if (!newV && StringUtils.isNotBlank(motif.getText()) && ModalUtil.confirm("Effacer le motif ?", "Effacer le motif ?")) { motif.clear(); } }); Bindings.bindBidirectional(motif.textProperty(), eleveData.MotifProperty()); motif.textProperty().addListener((o, oldV, newV) -> { if (StringUtils.isNotBlank(newV)) { exclus.setSelected(true); } }); GridPane.setMargin(motif, new Insets(0, 10, 0, 0)); sanctionsGrid.add(motif, 7, rowIndex, HPos.LEFT); }
From source file:dsfixgui.view.DSFGraphicsPane.java
private void recheckTextInputUnsafe(TextField field) { String text = field.getText(); field.setText(""); field.appendText(text);/*from ww w.j a va 2 s. c o m*/ }
From source file:dsfixgui.view.DSFGraphicsPane.java
private void recheckTextInput(TextField field) { String newText = field.getText(); if (field.equals(renderWidthField)) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) >= 1280) { if (NumberUtils.isParsable(presentWidthField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(presentWidthField.getText()))) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false); renderWidthField.setTooltip(new Tooltip("")); config.setRenderWidth(Integer.parseInt(newText)); if (config.disableDOF) { config.setPresentWidth(Integer.parseInt(newText)); }//from w w w . ja v a 2s . c o m } //If input is a positive integer that is less than 1280, present width comes into play } else if (NumberUtils.isParsable(presentWidthField.getText()) && Integer.parseInt(presentWidthField.getText()) >= 1280) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false); renderWidthField.setTooltip(new Tooltip("")); config.setRenderWidth(Integer.parseInt(newText)); } else { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(PRES_WIDTH_TOO_LOW)); } } else if (field.equals(renderHeightField)) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) >= 720) { if (NumberUtils.isParsable(presentHeightField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(presentHeightField.getText()))) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false); renderHeightField.setTooltip(new Tooltip("")); config.setRenderHeight(Integer.parseInt(newText)); if (config.disableDOF) { config.setPresentHeight(Integer.parseInt(newText)); config.setDOFOverride(Integer.parseInt(newText)); } } //If input is a positive integer that is less than 720, present height comes into play } else if (NumberUtils.isParsable(presentHeightField.getText()) && Integer.parseInt(presentHeightField.getText()) >= 720) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false); renderHeightField.setTooltip(new Tooltip("")); config.setRenderHeight(Integer.parseInt(newText)); } else { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(PRES_HEIGHT_TOO_LOW)); } } else if (field.equals(presentWidthField) && !presentWidthField.isDisabled()) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) < 1280) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 1280)); } else if (Integer.parseInt(newText) >= 1280) { if (NumberUtils.isParsable(renderWidthField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(renderWidthField.getText()))) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false); presentWidthField.setTooltip(null); config.setPresentWidth(Integer.parseInt(newText)); } } } else if (field.equals(presentWidthField) && presentWidthField.isDisabled()) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false); presentWidthField.setTooltip(null); } else if (field.equals(presentHeightField) && !presentHeightField.isDisabled()) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) < 720) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 720)); } else if (Integer.parseInt(newText) >= 720) { if (NumberUtils.isParsable(renderHeightField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(renderHeightField.getText()))) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false); presentHeightField.setTooltip(null); config.setPresentHeight(Integer.parseInt(newText)); } } } else if (field.equals(presentHeightField) && presentHeightField.isDisabled()) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false); presentHeightField.setTooltip(null); } else if (field.equals(fpsLimitField) && !fpsLimitField.isDisabled()) { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true); fpsLimitField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) > 70) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true); fpsLimitField.setTooltip(new Tooltip(INPUT_FPS_TOO_HIGH)); } else { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, false); fpsLimitField.setTooltip(new Tooltip(FPS_LIMIT_LABEL.substring(0, FPS_LIMIT_LABEL.length() - 2))); config.FPSlimit.set(Integer.parseInt(newText)); } } else if (field.equals(fpsLimitField) && fpsLimitField.isDisabled()) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, false); fpsLimitField.setTooltip(new Tooltip("")); } }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;//from www . j a v a2s . co m final GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); TableView tv = new TableView(); final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name"); final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount"); final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove"); firstDataColumn.setMinWidth(130); secondDataColumn.setMinWidth(130); thirdDataColumn.setMinWidth(130); if (!pfname.equals("")) { firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey)); rows = 0; tv = new TableView<>(generateDataInMap(pfname, addPairs)); } tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn); // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn()); ScrollPane sp = new ScrollPane(); sp.setMinWidth(400); sp.setHbarPolicy(ScrollBarPolicy.NEVER); sp.setContent(tv); grid.add(sp, 0, 3); final ComboBox comboBox = new ComboBox(); HBox hb1 = new HBox(); comboBox.setValue("FILE"); comboBox.getItems().addAll("Save this file", "Load a new file"); Button btnOk = new Button(); btnOk.setText("OK"); hb1.getChildren().addAll(comboBox, btnOk); hb1.setSpacing(10); grid.add(hb1, 0, 1); Label label1 = new Label("Title:"); final TextField tfFilename = new TextField(); tfFilename.setText(getTitle(pfname)); HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); grid.add(hb, 0, 2); final Stage ps = new Stage(); final TableView tv1 = tv; btnOk.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (comboBox.getValue().equals("Load a new file")) { first(ps); st.close(); } else { PrintWriter pw = null; try { pw = new PrintWriter("abc.json"); BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false)); bw.write("{title:\"" + tfFilename.getText() + "\""); bw.write(",fruits:["); for (int i = 0; i < rows; i++) { bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:" + String.valueOf(secondDataColumn.getCellData(i)) + "}"); if (i != rows - 1) bw.write(","); } bw.write("]}"); bw.close(); } catch (Exception e) { System.out.println(e.toString()); } } } }); Button btn = new Button(); btn.setText("New Fruit"); grid.add(btn, 1, 2); // TableView tv=new TableView(); // TableColumn Col1 = new TableColumn("Name"); // TableColumn Col2 = new TableColumn("Amount"); // TableColumn Col3 = new TableColumn("Remove"); // tv.getColumns().addAll(Col1, Col2, Col3); //sp.setFitToWidth(true); Image img = new Image("file:music.jpg"); ImageView iv2 = new ImageView(); iv2.setImage(img); iv2.setFitWidth(200); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); grid.add(iv2, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); System.out.println(comboBox.valueProperty()); st.close(); third(pfname); } }); scene = new Scene(grid, 700, 450); st.setScene(scene); st.show(); }
From source file:tachyon.view.ProjectProperties.java
public ProjectProperties(JavaProject project, Window w) { this.project = project; stage = new Stage(); stage.initOwner(w);/* www .j a v a 2 s. c om*/ stage.initModality(Modality.APPLICATION_MODAL); stage.setWidth(600); stage.setTitle("Project Properties - " + project.getProjectName()); stage.getIcons().add(tachyon.Tachyon.icon); stage.setResizable(false); HBox mai, libs, one, two, thr, fou; ListView<String> compileList, runtimeList; Button compileAdd, compileRemove, preview, selectIm, runtimeAdd, runtimeRemove; TextField iconField; stage.setScene(new Scene(new VBox(5, pane = new TabPane( new Tab("Library Settings", box1 = new VBox(15, libs = new HBox(10, new Label("External Libraries"), libsView = new ListView<>(), new VBox(5, addJar = new Button("Add Jar"), removeJar = new Button("Remove Jar"))))), new Tab("Program Settings", new ScrollPane(box2 = new VBox(15, one = new HBox(10, new Label("Main-Class"), mainClass = new TextField(project.getMainClassName()), select = new Button("Select")), two = new HBox(10, new Label("Compile-Time Arguments"), compileList = new ListView<>(), new VBox(5, compileAdd = new Button("Add Argument"), compileRemove = new Button("Remove Argument")))))), new Tab("Deployment Settings", box3 = new VBox(15, thr = new HBox(10, new Label("Icon File"), iconField = new TextField(project.getFileIconPath()), preview = new Button("Preview Image"), selectIm = new Button("Select Icon")), fou = new HBox(10, new Label("Runtime Arguments"), runtimeList = new ListView<>(), new VBox(5, runtimeAdd = new Button("Add Argument"), runtimeRemove = new Button("Remove Argument")))))), new VBox(15, mai = new HBox(10, cancel = new Button("Cancel"), confirm = new Button("Confirm")))))); if (applyCss.get()) { stage.getScene().getStylesheets().add(css); } for (Tab b : pane.getTabs()) { b.setClosable(false); } mainClass.setPromptText("Main-Class"); box1.setPadding(new Insets(5, 10, 5, 10)); mai.setAlignment(Pos.CENTER_RIGHT); mai.setPadding(box1.getPadding()); libs.setAlignment(Pos.CENTER); one.setAlignment(Pos.CENTER); two.setAlignment(Pos.CENTER); thr.setAlignment(Pos.CENTER); fou.setAlignment(Pos.CENTER); box1.setAlignment(Pos.CENTER); box2.setPadding(box1.getPadding()); box2.setAlignment(Pos.CENTER); box3.setPadding(box1.getPadding()); box3.setAlignment(Pos.CENTER); mainClass.setEditable(false); mainClass.setPrefWidth(200); for (JavaLibrary lib : project.getAllLibs()) { libsView.getItems().add(lib.getBinaryAbsolutePath()); } for (String sa : project.getCompileTimeArguments().keySet()) { compileList.getItems().add(sa + ":" + project.getCompileTimeArguments().get(sa)); } for (String sa : project.getRuntimeArguments()) { runtimeList.getItems().add(sa); } compileAdd.setOnAction((e) -> { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Compiler Argument"); dialog.initOwner(stage); dialog.setHeaderText("Entry the argument"); ButtonType loginButtonType = new ButtonType("Done", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField username = new TextField(); username.setPromptText("Key"); TextField password = new TextField(); password.setPromptText("Value"); grid.add(new Label("Key:"), 0, 0); grid.add(username, 1, 0); grid.add(new Label("Value:"), 0, 1); grid.add(password, 1, 1); Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); username.textProperty().addListener((observable, oldValue, newValue) -> { loginButton.setDisable(newValue.trim().isEmpty()); }); dialog.getDialogPane().setContent(grid); Platform.runLater(() -> username.requestFocus()); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { return new Pair<>(username.getText(), password.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); if (result.isPresent()) { compileList.getItems().add(result.get().getKey() + ":" + result.get().getValue()); } }); compileRemove.setOnAction((e) -> { if (compileList.getSelectionModel().getSelectedItem() != null) { compileList.getItems().remove(compileList.getSelectionModel().getSelectedItem()); } }); runtimeAdd.setOnAction((e) -> { TextInputDialog dia = new TextInputDialog(); dia.setTitle("Add Runtime Argument"); dia.setHeaderText("Enter an argument"); dia.initOwner(stage); Optional<String> res = dia.showAndWait(); if (res.isPresent()) { runtimeList.getItems().add(res.get()); } }); runtimeRemove.setOnAction((e) -> { if (runtimeList.getSelectionModel().getSelectedItem() != null) { runtimeList.getItems().remove(runtimeList.getSelectionModel().getSelectedItem()); } }); preview.setOnAction((e) -> { if (!iconField.getText().isEmpty()) { if (iconField.getText().endsWith(".ico")) { List<BufferedImage> read = new ArrayList<>(); try { read.addAll(ICODecoder.read(new File(iconField.getText()))); } catch (IOException ex) { } if (read.size() >= 1) { Image im = SwingFXUtils.toFXImage(read.get(0), null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } else if (iconField.getText().endsWith(".icns")) { try { BufferedImage ima = Imaging.getBufferedImage(new File(iconField.getText())); if (ima != null) { Image im = SwingFXUtils.toFXImage(ima, null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } catch (ImageReadException | IOException ex) { } } else { Image im = new Image(new File(iconField.getText()).toURI().toString()); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } }); selectIm.setOnAction((e) -> { FileChooser fc = new FileChooser(); fc.setTitle("Icon File"); String OS = System.getProperty("os.name").toLowerCase(); fc.getExtensionFilters().add(new ExtensionFilter("Icon File", OS.contains("win") ? getWindowsImageExtensions() : getMacImageExtensions())); fc.setSelectedExtensionFilter(fc.getExtensionFilters().get(0)); File lf = fc.showOpenDialog(stage); if (lf != null) { iconField.setText(lf.getAbsolutePath()); } }); addJar.setOnAction((e) -> { FileChooser f = new FileChooser(); f.setTitle("External Libraries"); f.setSelectedExtensionFilter(new ExtensionFilter("Jar Files", "*.jar")); List<File> showOpenMultipleDialog = f.showOpenMultipleDialog(stage); if (showOpenMultipleDialog != null) { for (File fi : showOpenMultipleDialog) { if (!libsView.getItems().contains(fi.getAbsolutePath())) { libsView.getItems().add(fi.getAbsolutePath()); } } } }); removeJar.setOnAction((e) -> { String selected = libsView.getSelectionModel().getSelectedItem(); if (selected != null) { libsView.getItems().remove(selected); } }); select.setOnAction((e) -> { List<String> all = getAll(); ChoiceDialog<String> di = new ChoiceDialog<>(project.getMainClassName(), all); di.setTitle("Select Main Class"); di.initOwner(stage); di.setHeaderText("Select A Main Class"); Optional<String> show = di.showAndWait(); if (show.isPresent()) { mainClass.setText(show.get()); } }); cancel.setOnAction((e) -> { stage.close(); }); confirm.setOnAction((e) -> { project.setMainClassName(mainClass.getText()); project.setFileIconPath(iconField.getText()); project.setRuntimeArguments(runtimeList.getItems()); HashMap<String, String> al = new HashMap<>(); for (String s : compileList.getItems()) { String[] spl = s.split(":"); al.put(spl[0], spl[1]); } project.setCompileTimeArguments(al); project.setAllLibs(libsView.getItems()); stage.close(); }); }
From source file:FeeBooster.java
private GridPane cpfpGrid(Transaction tx) { // Setup Grid GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);//from w ww .j a va 2s . com grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); int gridheight = 0; // Add outputs to table Label outputHdrLbl = new Label("Outputs"); grid.add(outputHdrLbl, 1, gridheight); gridheight++; ToggleGroup outputGroup = new ToggleGroup(); for (int i = 0; i < tx.getOutputs().size(); i++) { // Add output to table TxOutput out = tx.getOutputs().get(i); Text outputTxt = new Text("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress()); outputTxt.setUserData(i); grid.add(outputTxt, 0, gridheight); // Add radio button to table RadioButton radio = new RadioButton(); radio.setUserData(i); radio.setToggleGroup(outputGroup); radio.setSelected(true); grid.add(radio, 1, gridheight); gridheight++; } // Fee Text fee = new Text("Fee to Pay: " + tx.getFee() + " Satoshis"); grid.add(fee, 0, gridheight); // Recommended fee from bitcoinfees.21.co JSONObject apiResult = Utils.getFromAnAPI("http://bitcoinfees.21.co/api/v1/fees/recommended", "GET"); int fastestFee = apiResult.getInt("fastestFee"); long recommendedFee = fastestFee * tx.getSize() + fastestFee * 300; Text recFeeTxt = new Text("Recommended Fee: " + recommendedFee + " Satoshis"); grid.add(recFeeTxt, 1, gridheight); gridheight += 2; // Instructions Text instructions = new Text("Choose an output to spend from. Set the total transaction fee below."); grid.add(instructions, 0, gridheight, 3, 1); gridheight++; // Fee spinner Spinner feeSpin = new Spinner((double) tx.getFee(), (double) tx.getTotalAmt(), (double) tx.getFee()); feeSpin.setEditable(true); grid.add(feeSpin, 0, gridheight); feeSpin.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { double oldVal = (double) oldValue; double newVal = (double) newValue; Double step = newVal - oldVal; tx.setFee(tx.getFee() + step.longValue()); fee.setText("Fee to Pay: " + tx.getFee() + " Satoshis"); } }); // Set to recommended fee button Button recFeeBtn = new Button("Set fee to recommended"); grid.add(recFeeBtn, 1, gridheight); gridheight++; recFeeBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { long prevFee = tx.getFee(); long step = recommendedFee - prevFee; feeSpin.increment((int) step); } }); // Output address Label recvAddr = new Label("Address to pay to"); grid.add(recvAddr, 0, gridheight); TextField outAddr = new TextField(); grid.add(outAddr, 1, gridheight); gridheight++; // Next Button Button nextBtn = new Button("Next"); nextBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (sceneCursor == scenes.size() - 1) { // Referenced output int output = (int) outputGroup.getSelectedToggle().getUserData(); TxOutput refout = tx.getOutputs().get(output); // Create output for CPFP transaction TxOutput out = null; long outval = refout.getValue() - ((Double) feeSpin.getValue()).longValue(); if (Utils.validateAddress(outAddr.getText())) { byte[] decodedAddr = Utils.base58Decode(outAddr.getText()); boolean isP2SH = decodedAddr[0] == 0x00; byte[] hash160 = Arrays.copyOfRange(decodedAddr, 1, decodedAddr.length - 4); if (isP2SH) { byte[] script = new byte[hash160.length + 3]; script[0] = (byte) 0xa9; script[1] = (byte) 0x14; System.arraycopy(hash160, 0, script, 2, hash160.length); script[script.length - 1] = (byte) 0x87; out = new TxOutput(outval, script); } else { byte[] script = new byte[hash160.length + 5]; script[0] = (byte) 0x76; script[1] = (byte) 0xa9; script[2] = (byte) 0x14; System.arraycopy(hash160, 0, script, 3, hash160.length); script[script.length - 2] = (byte) 0x88; script[script.length - 1] = (byte) 0xac; out = new TxOutput(outval, script); } } else { Alert alert = new Alert(Alert.AlertType.ERROR, "Invalid Address"); alert.showAndWait(); return; } // Create CPFP Transaction Transaction cpfpTx = new Transaction(); TxInput in = new TxInput(tx.getHash(), output, new byte[] { (0x00) }, 0xffffffff); cpfpTx.addOutput(out); cpfpTx.addInput(in); // Create Scene Scene scene = new Scene(unsignedTxGrid(cpfpTx), 900, 500); scenes.add(scene); sceneCursor++; stage.setScene(scene); } else { sceneCursor++; stage.setScene(scenes.get(sceneCursor)); } } }); HBox btnHbox = new HBox(10); // Back Button Button backBtn = new Button("Back"); backBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { sceneCursor--; stage.setScene(scenes.get(sceneCursor)); } }); btnHbox.getChildren().add(backBtn); btnHbox.getChildren().add(nextBtn); // Cancel Button Button cancelBtn = new Button("Cancel"); cancelBtn.setOnAction(cancelEvent); btnHbox.getChildren().add(cancelBtn); grid.add(btnHbox, 1, gridheight); return grid; }
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 w w . j av a 2 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(); }
From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java
private Optional<String> askUserForTextField(String text) { TextField textfield = new TextField(); Dialog<ButtonType> dialog = new Dialog<>(); dialog.getDialogPane().headerTextProperty().set(text); dialog.getDialogPane().contentProperty().set(textfield); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); Optional<ButtonType> result = dialog.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) return Optional.of(textfield.getText()); else/*from w w w . ja v a2 s .com*/ return Optional.empty(); }