List of usage examples for javafx.scene.control TextField getText
public final String getText()
From source file:account.management.controller.NewVoucherController.java
private void validateFields() { int dr_counter = 0, cr_counter = 0; float total_dr = 0f, total_cr = 0f; for (int i = 0; i < field_container.getChildren().size(); i++) { HBox row = (HBox) field_container.getChildren().get(i); TextField dr = (TextField) row.getChildren().get(1); TextField cr = (TextField) row.getChildren().get(2); if (dr.getText().equals("") && cr.getText().equals("")) { this.button_submit.setDisable(true); return; }//from w w w . j a v a2 s .c om if (!dr.getText().equals("") && !cr.getText().equals("")) { this.button_submit.setDisable(true); return; } /* * regular expression check */ Pattern pattern = Pattern.compile("^[0-9]*\\.?[0-9]+$"); Matcher match = pattern.matcher(dr.getText()); if (!dr.getText().equals("") && !match.find()) { this.button_submit.setDisable(true); return; } match = pattern.matcher(cr.getText()); if (!cr.getText().equals("") && !match.find()) { this.button_submit.setDisable(true); return; } if (!dr.getText().equals("")) { dr_counter++; total_dr += Float.parseFloat(dr.getText()); } if (!cr.getText().equals("")) { cr_counter++; total_cr += Float.parseFloat(cr.getText()); } } if ((dr_counter > 1 && cr_counter > 1) || dr_counter == 0 || cr_counter == 0 || (total_dr != total_cr)) { this.button_submit.setDisable(true); return; } this.button_submit.setDisable(false); }
From source file:account.management.controller.POVoucherController.java
public void calculate() { int len = this.container.getChildren().size(); double total_amount = 0; for (int i = 0; i < len; i++) { HBox row = (HBox) this.container.getChildren().get(i); TextField sl_t = (TextField) row.getChildren().get(0); TextField qty_t = (TextField) row.getChildren().get(2); TextField rate_t = (TextField) row.getChildren().get(3); TextField total_t = (TextField) row.getChildren().get(4); TextField commision_t = (TextField) row.getChildren().get(5); TextField total_commision_t = (TextField) row.getChildren().get(6); TextField neat_amount_t = (TextField) row.getChildren().get(7); sl_t.setText(String.valueOf(i + 1)); double qty = qty_t.getText().isEmpty() ? 0 : Double.parseDouble(qty_t.getText()); double rate = rate_t.getText().isEmpty() ? 0 : Double.parseDouble(rate_t.getText()); double total = total_t.getText().isEmpty() ? 0 : Double.parseDouble(total_t.getText()); double commision = commision_t.getText().isEmpty() ? 0 : Double.parseDouble(commision_t.getText()); double total_commision = total_commision_t.getText().isEmpty() ? 0 : Double.parseDouble(total_commision_t.getText()); double neat_amount = neat_amount_t.getText().isEmpty() ? 0 : Double.parseDouble(neat_amount_t.getText()); total = qty * rate;//w w w. ja v a2 s . c om total_commision = total * commision / 100; neat_amount = total - total_commision; total_t.setText(String.valueOf(total)); total_commision_t.setText(String.valueOf(total_commision)); neat_amount_t.setText(String.valueOf(neat_amount)); total_amount += neat_amount; } this.total_price.setText(String.valueOf(total_amount)); }
From source file:fruitproject.FruitProject.java
public void third(final String pfname) { final Stage st = new Stage(); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);// w w w .j a v a2s . c o m grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); Label label1 = new Label("New Fruit"); grid.add(label1, 1, 0); final TextField txtName = new TextField(); grid.add(txtName, 1, 1); final TextField txtAmount = new TextField(); grid.add(txtAmount, 1, 2); Button btn = new Button(); btn.setText("OK"); grid.add(btn, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); addPairs.add(txtName.getText()); addPairs.add(txtAmount.getText()); st.close(); second(pfname); } }); Scene scene = new Scene(grid, 500, 500); st.setScene(scene); st.show(); }
From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java
private TextField createIntegerInputField(final TextField textInput, final Supplier<Integer> getter, final Consumer<Integer> setter) { final TextField integerInput = new TextField(getter.get() == null ? "" : String.valueOf(getter.get())); integerInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { if (!newValue.matches("\\d*")) { integerInput.setText(newValue.replaceAll("[^\\d]", "")); newValue = textInput.getText(); }/* w ww. j ava 2s .c om*/ if (StringUtils.isNotBlank(newValue)) { try { setter.accept(Integer.parseInt(newValue)); } catch (final NumberFormatException nfe) { // This can only happen if the value is "too long" / too high for "int" integerInput.setText(String.valueOf(Integer.MAX_VALUE)); setter.accept(Integer.MAX_VALUE); } } else { setter.accept(null); } this.setChanged(true); }); final double maxWidthOfIntegerInput = 80d; integerInput.setMaxWidth(maxWidthOfIntegerInput); return integerInput; }
From source file:hd3gtv.as5kpc.Serverchannel.java
private String makeName(String suffix_label, TextField showname) { StringBuilder sb = new StringBuilder(); Calendar c = Calendar.getInstance(); if (c.get(Calendar.DAY_OF_MONTH) < 10) { sb.append("0"); }//from w w w . j a v a2s . c o m sb.append(c.get(Calendar.DAY_OF_MONTH)); sb.append("-"); if (c.get(Calendar.MONTH) + 1 < 10) { sb.append("0"); } sb.append(c.get(Calendar.MONTH) + 1); sb.append(" "); String show_name = showname.getText(); show_name = PATTERN_Combining_Diacritical_Marks .matcher(Normalizer.normalize(showname.getText(), Normalizer.Form.NFD)).replaceAll("").trim() .toUpperCase(); showname.setText(show_name); sb.append(show_name); if (show_name.endsWith(suffix_label) == false) { sb.append(" "); sb.append(suffix_label); } return sb.toString(); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createBannedIP(ListView<String> to_update) { Stage createBannedIP = new Stage(); createBannedIP.setTitle("Add Banned IP"); createBannedIP.initModality(Modality.APPLICATION_MODAL); GridPane gp = new GridPane(); gp.setPadding(new Insets(25, 25, 25, 25)); gp.setAlignment(Pos.CENTER);/*from www . j av a 2 s . co m*/ gp.setVgap(10); gp.setHgap(10); Text title = new Text("Add Banned IP"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); Label newusername = new Label("Ban IP"); TextField username = new TextField(); gp.add(newusername, 0, 1); gp.add(username, 1, 1); Button finish = new Button("Finish"); HBox finish_box = new HBox(10); finish_box.setAlignment(Pos.CENTER); finish_box.getChildren().add(finish); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_ips.remove(username.getText()); banned_ips.add(username.getText()); to_update.setItems(FXCollections.observableArrayList(banned_ips)); createBannedIP.close(); } }); gp.add(finish_box, 0, 2, 2, 1); Scene sc = new Scene(gp, 300, 175); createBannedIP.setScene(sc); createBannedIP.show(); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createBannedUser(ListView<String> to_update) { Stage createBannedUser = new Stage(); createBannedUser.setTitle("Add Banned User"); createBannedUser.initModality(Modality.APPLICATION_MODAL); GridPane gp = new GridPane(); gp.setPadding(new Insets(25, 25, 25, 25)); gp.setAlignment(Pos.CENTER);/*from ww w . java2 s. com*/ gp.setVgap(10); gp.setHgap(10); Text title = new Text("Add Banned Username"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); Label newusername = new Label("Ban Username"); TextField username = new TextField(); gp.add(newusername, 0, 1); gp.add(username, 1, 1); Button finish = new Button("Finish"); HBox finish_box = new HBox(10); finish_box.setAlignment(Pos.CENTER); finish_box.getChildren().add(finish); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_usernames.remove(username.getText()); banned_usernames.add(username.getText()); to_update.setItems(FXCollections.observableArrayList(banned_usernames)); createBannedUser.close(); } }); gp.add(finish_box, 0, 2, 2, 1); Scene sc = new Scene(gp, 300, 175); createBannedUser.setScene(sc); createBannedUser.show(); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createBannedPlayername(ListView<String> to_update) { Stage createBannedPlayername = new Stage(); createBannedPlayername.setTitle("Add Banned Playername"); createBannedPlayername.initModality(Modality.APPLICATION_MODAL); GridPane gp = new GridPane(); gp.setPadding(new Insets(25, 25, 25, 25)); gp.setAlignment(Pos.CENTER);/*from www. j a v a 2 s . c o m*/ gp.setVgap(10); gp.setHgap(10); Text title = new Text("Add Banned Playername"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); Label newusername = new Label("Ban Playername"); TextField username = new TextField(); gp.add(newusername, 0, 1); gp.add(username, 1, 1); Button finish = new Button("Finish"); HBox finish_box = new HBox(10); finish_box.setAlignment(Pos.CENTER); finish_box.getChildren().add(finish); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_playernames.remove(username.getText()); banned_playernames.add(username.getText()); to_update.setItems(FXCollections.observableArrayList(banned_playernames)); createBannedPlayername.close(); } }); gp.add(finish_box, 0, 2, 2, 1); Scene sc = new Scene(gp, 300, 175); createBannedPlayername.setScene(sc); createBannedPlayername.show(); }
From source file:account.management.controller.POVoucherController.java
@FXML private void onSubmitButtonClick(ActionEvent event) throws ParseException { try {/*ww w .ja v a 2 s . c o m*/ JSONArray array = new JSONArray(); int len = this.container.getChildren().size(); for (int i = 0; i < len; i++) { HBox row = (HBox) this.container.getChildren().get(i); TextField sl_t = (TextField) row.getChildren().get(0); TextField desc_t = (TextField) row.getChildren().get(1); TextField qty_t = (TextField) row.getChildren().get(2); TextField rate_t = (TextField) row.getChildren().get(3); TextField total_t = (TextField) row.getChildren().get(4); TextField commision_t = (TextField) row.getChildren().get(5); TextField total_commision_t = (TextField) row.getChildren().get(6); TextField neat_amount_t = (TextField) row.getChildren().get(7); JSONObject obj = new JSONObject(); obj.put("sl", sl_t.getText()); obj.put("desc", desc_t.getText()); obj.put("qty", qty_t.getText()); obj.put("rate", rate_t.getText()); obj.put("total", total_t.getText()); obj.put("commision", commision_t.getText()); obj.put("total_commision", total_commision_t.getText()); obj.put("neat_amount", neat_amount_t.getText()); array.put(obj); } JSONArray res = Unirest.get(MetaData.baseUrl + "add/purchase/order") .queryString("name", this.name.getText()).queryString("address", this.address.getText()) .queryString("date", this.date.getValue().toString()) .queryString("total_price", this.total_price.getText()) .queryString("shabek", this.opening.getText()) .queryString("grand_total", this.grand_total.getText()) .queryString("tt_dd_cash", this.cash.getText()).queryString("jer", this.balance.getText()) .queryString("content", array).asJson().getBody().getArray(); JSONObject obj = res.getJSONObject(0); if (obj.getString("Status").equals("Success")) { String voucher_no = Unirest.get(MetaData.baseUrl + "purchase/order/lastId").asString().getBody(); Msg.showInformation("Success"); showReport(voucher_no, this.name.getText(), this.address.getText(), this.date.getValue().toString(), array.toString(), this.total_price.getText(), this.opening.getText(), this.grand_total.getText(), this.cash.getText(), this.balance.getText()); } else { Msg.showError(obj.getString("Message")); } } catch (UnirestException ex) { Logger.getLogger(POVoucherController.class.getName()).log(Level.SEVERE, null, ex); Msg.showError(""); } }
From source file:account.management.controller.SellVoucherController.java
@FXML private void onSubmitButtonClick(ActionEvent event) throws ParseException { try {//from w ww.ja v a 2 s. c o m JSONArray array = new JSONArray(); int len = this.container.getChildren().size(); for (int i = 0; i < len; i++) { HBox row = (HBox) this.container.getChildren().get(i); TextField sl_t = (TextField) row.getChildren().get(0); TextField desc_t = (TextField) row.getChildren().get(1); TextField qty_t = (TextField) row.getChildren().get(2); TextField rate_t = (TextField) row.getChildren().get(3); TextField total_t = (TextField) row.getChildren().get(4); TextField commision_t = (TextField) row.getChildren().get(5); TextField total_commision_t = (TextField) row.getChildren().get(6); TextField neat_amount_t = (TextField) row.getChildren().get(7); JSONObject obj = new JSONObject(); obj.put("sl", sl_t.getText()); obj.put("desc", desc_t.getText()); obj.put("qty", qty_t.getText()); obj.put("rate", rate_t.getText()); obj.put("total", total_t.getText()); obj.put("commision", commision_t.getText()); obj.put("total_commision", total_commision_t.getText()); obj.put("neat_amount", neat_amount_t.getText()); array.put(obj); } JSONArray res = Unirest.get(MetaData.baseUrl + "add/sell/order") .queryString("name", this.name.getText()).queryString("address", this.address.getText()) .queryString("date", this.date.getValue().toString()) .queryString("total_price", this.total_price.getText()) .queryString("shabek", this.opening.getText()) .queryString("grand_total", this.grand_total.getText()) .queryString("tt_dd_cash", this.cash.getText()).queryString("jer", this.balance.getText()) .queryString("content", array).asJson().getBody().getArray(); JSONObject obj = res.getJSONObject(0); if (obj.getString("Status").equals("Success")) { String voucher_no = Unirest.get(MetaData.baseUrl + "sell/order/lastId").asString().getBody(); Msg.showInformation("Success"); showReport(voucher_no, this.name.getText(), this.address.getText(), this.date.getValue().toString(), array.toString(), this.total_price.getText(), this.opening.getText(), this.grand_total.getText(), this.cash.getText(), this.balance.getText()); } else { Msg.showError(obj.getString("Message")); } } catch (UnirestException ex) { Logger.getLogger(POVoucherController.class.getName()).log(Level.SEVERE, null, ex); Msg.showError(""); } }