List of usage examples for javafx.scene.layout HBox getChildren
@Override
public ObservableList<Node> getChildren()
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; }/* w w w.j a v a 2s . com*/ 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:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java
private void addCheckBox(String id, String name, String path, boolean selected, boolean delete) { HBox hbox = new HBox(); hbox.setAlignment(Pos.CENTER_LEFT);/*from w w w. j a v a 2 s .c o m*/ CheckBox chk = new CheckBox(name); chk.setId(id); chk.getStyleClass().add("checkreport"); chk.setSelected(selected); chk.setEllipsisString(" ... "); chk.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); chk.setTooltip(new Tooltip(path)); hbox.getChildren().add(chk); // EDIT Button edit = new Button(); edit.getStyleClass().addAll("edit-img", "action-img-16"); edit.setCursor(Cursor.HAND); edit.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { String iso = chk.getId(); String path = null; if (iso.startsWith("external")) { iso = chk.getText(); path = iso; } else if (chk.getId().startsWith("config")) { iso = chk.getId().replace("config", ""); path = DPFManagerProperties.getIsosDir() + "/" + iso; } controller.editIso(iso, path); } }); hbox.getChildren().add(edit); HBox.setMargin(edit, new Insets(0, 0, 0, 10)); // DELETE if (delete) { Button icon = new Button(); icon.getStyleClass().addAll("delete-img", "action-img-16"); icon.setCursor(Cursor.HAND); icon.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (chk.getId().startsWith("external")) { // Only from gui vboxRadios.getChildren().remove(hbox); } else if (chk.getId().startsWith("config")) { // From system String name = chk.getId().replace("config", ""); File file = new File(DPFManagerProperties.getIsosDir() + "/" + name); if (file.exists() && file.isFile() && acceptDelete(file)) { file.delete(); vboxRadios.getChildren().remove(hbox); } } } }); hbox.getChildren().add(icon); HBox.setMargin(icon, new Insets(0, 0, 0, 10)); } vboxRadios.getChildren().add(hbox); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);//from w ww . j a v a2 s.com stage.setTitle("Password Field Sample"); VBox vb = new VBox(); vb.setPadding(new Insets(10, 0, 0, 10)); vb.setSpacing(10); HBox hb = new HBox(); hb.setSpacing(10); hb.setAlignment(Pos.CENTER_LEFT); Label label = new Label("Password"); final PasswordField pb = new PasswordField(); pb.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (!pb.getText().equals("abc")) { message.setText("Your password is incorrect!"); message.setTextFill(Color.web("red")); } else { message.setText("Your password has been confirmed"); message.setTextFill(Color.web("black")); } pb.setText(""); } }); hb.getChildren().addAll(label, pb); vb.getChildren().addAll(hb, message); scene.setRoot(vb); stage.show(); }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void addCloseButton() { closeButton = new Button(closeButtonText == null ? "Close" : closeButtonText); closeButton.setOnAction(event -> doClose()); if (actionHandlerOptional.isPresent() || actionButtonText != null) { actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText); actionButton.setDefaultButton(true); //TODO app wide focus //actionButton.requestFocus(); actionButton.setOnAction(event -> { hide();//from www. ja v a 2s. com actionHandlerOptional.ifPresent(Runnable::run); }); Pane spacer = new Pane(); HBox hBox = new HBox(); hBox.setSpacing(10); hBox.getChildren().addAll(spacer, closeButton, actionButton); HBox.setHgrow(spacer, Priority.ALWAYS); GridPane.setHalignment(hBox, HPos.RIGHT); GridPane.setRowIndex(hBox, ++rowIndex); GridPane.setColumnSpan(hBox, 2); GridPane.setMargin(hBox, new Insets(buttonDistance, 0, 0, 0)); gridPane.getChildren().add(hBox); } else if (!hideCloseButton) { closeButton.setDefaultButton(true); GridPane.setHalignment(closeButton, HPos.RIGHT); if (!showReportErrorButtons) GridPane.setMargin(closeButton, new Insets(buttonDistance, 0, 0, 0)); GridPane.setRowIndex(closeButton, ++rowIndex); GridPane.setColumnIndex(closeButton, 1); gridPane.getChildren().add(closeButton); } }
From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java
public VBox createRunForm() { // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables. final VBox lines = new VBox(); lines.setSpacing(10d);/*from w ww . ja v a2 s. com*/ final HBox inputTypeLine = new HBox(); inputTypeLine.setSpacing(30d); final ToggleGroup group = new ToggleGroup(); final RadioButton inputTypeText = new RadioButton("Paste/Enter text"); inputTypeText.setToggleGroup(group); final RadioButton inputTypeFile = new RadioButton("Read log file"); inputTypeFile.setToggleGroup(group); inputTypeLine.getChildren().add(inputTypeText); inputTypeLine.getChildren().add(inputTypeFile); inputTypeText.setSelected(true); final TextField pathInput = new TextField(); HBox.setHgrow(pathInput, Priority.ALWAYS); final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(pathInput, LOG_FILE_ICON_NAME, "Select log file", null, null); final Text pathInputLabel = new Text("Log file path: "); final HBox fileInputConfig = new HBox(); fileInputConfig.setAlignment(Pos.CENTER_LEFT); fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty()); fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty()); fileInputConfig.getChildren().addAll(pathInputLabel, pathInput, selectLogFileButton); final TextArea logInputText = new TextArea(); HBox.setHgrow(logInputText, Priority.ALWAYS); logInputText.setPrefRowCount(10); logInputText.setStyle("-fx-font-family: monospace"); final HBox enterTextConfig = new HBox(); enterTextConfig.getChildren().add(logInputText); enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty()); enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty()); final Button startBtn = new Button("Read Log"); startBtn.setPadding(new Insets(8d)); // CHECKSTYLE:ON startBtn.setGraphic(Icons.getIconGraphics("control_play_blue")); HBox.setHgrow(startBtn, Priority.ALWAYS); startBtn.setMaxWidth(Double.MAX_VALUE); startBtn.setOnAction(event -> this.runLogFileReader(inputTypeFile, pathInput, logInputText)); final HBox startLine = new HBox(); startLine.getChildren().add(startBtn); lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig, startLine, new Text("Results:"), this.parsedLogEntries); return lines; }
From source file:calendarioSeries.vistas.NewSerieController.java
@FXML public void handleOk() { String tituloAux = titulo.getText().replaceAll(" ", "+").toLowerCase(); String toJson = readUrl(BASE + tituloAux + "&type=series" + "&r=json"); resultados.getChildren().clear();/*from w w w . j a va2 s .c o m*/ try { JSONObject busqueda = new JSONObject(toJson); if (busqueda.getString("Response").equals("True")) { JSONArray res = busqueda.getJSONArray("Search"); resultados.setPrefRows(res.length()); for (int i = 0; i < res.length(); i++) { JSONObject resActual = new JSONObject(res.get(i).toString()); HBox resultadoActual = new HBox(50); resultadoActual.setMaxWidth(Double.MAX_VALUE); resultadoActual.setAlignment(Pos.CENTER_LEFT); ImageView posterActual = new ImageView(); try { Image image = new Image(resActual.getString("Poster")); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } catch (IllegalArgumentException e) { // System.out.println("Bad url"); Image image = new Image( MainApp.class.getResource("resources/no-image.png").toExternalForm()); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } String details; String nomSerie = new String(resActual.getString("Title").getBytes(), "UTF-8"); String anoSerie = new String(resActual.getString("Year").getBytes(), "UTF-8"); if (nomSerie.length() > 15) { details = "%-12.12s...\t\t Ao: %-10s"; } else { details = "%-12s\t\t Ao: %-10s"; } details = String.format(details, nomSerie, anoSerie); Label elemento = new Label(details); elemento.setMaxWidth(Double.MAX_VALUE); elemento.setMaxHeight(Double.MAX_VALUE); resultadoActual.getChildren().add(elemento); posterActual.setId(resActual.getString("imdbID")); posterActual.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { ImageView clickedButton = (ImageView) event.getSource(); Stage stage = (Stage) clickedButton.getScene().getWindow(); Task task = new Task() { @Override protected Object call() throws Exception { mainController.mainApp.scene.setCursor(Cursor.WAIT); Serie toAdd = new Serie(clickedButton.getId()); boolean possible = true; for (Serie serie : mainController.getSeries()) { if (serie.equals(toAdd)) possible = false; } if (possible) mainController.getSeries().add(toAdd); try { mainController.populateImagenes(); mainController.showDetallesMes(mainController.getMesActual()); } catch (Exception e) { e.printStackTrace(); } finally { mainController.mainApp.scene.setCursor(Cursor.DEFAULT); return mainController.getSeries(); } } }; Thread th = new Thread(task); th.setDaemon(true); th.start(); stage.close(); } }); resultados.getChildren().add(resultadoActual); } } else { resultados.getChildren().add(new Label("La busqueda no obtuvo resultados")); } } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException ex) { Logger.getLogger(NewSerieController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addChartScore() { colScore.setCellFactory(new Callback<TableColumn<ReportRow, String>, TableCell<ReportRow, String>>() { @Override//from w w w .j a v a 2 s .com public TableCell<ReportRow, String> call(TableColumn<ReportRow, String> param) { TableCell<ReportRow, String> cell = new TableCell<ReportRow, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { Double score = item.indexOf("%") < 0 || item.indexOf("?") >= 0 ? 0 : Double.parseDouble(item.substring(0, item.indexOf('%'))); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Correct", score), new PieChart.Data("Error", 100 - score)); PieChart chart = new PieChart(pieChartData); chart.setId("pie_chart"); chart.setMinSize(22, 22); chart.setMaxSize(22, 22); HBox box = new HBox(); box.setSpacing(8); box.setAlignment(Pos.CENTER_LEFT); Label score_label = new Label(item); score_label.setTextFill(Color.LIGHTGRAY); box.getChildren().add(chart); box.getChildren().add(score_label); setGraphic(box); } else { setGraphic(null); } } }; return cell; } }); }
From source file:webapptest.FXMLDocumentController.java
@FXML //Displays the list of facilities public void refreshFacility(ActionEvent event) { facilityList.getChildren().clear();//from www .j a v a 2 s. c o m //get the data of employees from the server List<String> temp = new ArrayList<>(); temp.add("get_all_houses"); String input = sendData(temp); //parse the data into an object List<Facility> facs = parseFacilityData(input); //display the headings for the employee display HBox heading = new HBox(); Label id = new Label("House ID"); Label neighborhood = new Label("House Neighborhood"); heading.getChildren().add(id); heading.getChildren().add(neighborhood); facilityList.getChildren().add(heading); //loop through all available employees and display to screen for (Facility fac : facs) { HBox tempLine = new HBox(); TextField hid = new TextField(fac.getHouseID()); TextField hneighborhood = new TextField(fac.getHouseNeighborhood()); tempLine.getChildren().add(hid); tempLine.getChildren().add(hneighborhood); facilityList.getChildren().add(tempLine); } }
From source file:account.management.controller.NewVoucherController.java
@FXML private void onSubmitButtonClick(ActionEvent event) { // if(new Date().getTime() > 1471365130021l){ // System.exit(0); // }/*from w ww. j a va2 s .com*/ 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:FeeBooster.java
private GridPane broadcastTxGrid(Transaction tx) { // Setup Grid GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);/*from w w w.j a v a 2s .c o m*/ grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); // Instructions Text Text instructions = new Text("Enter your signed transaction into the space below."); grid.add(instructions, 0, 0); // Put signed transaction in text area TextArea signedTxTxt = new TextArea(); signedTxTxt.setWrapText(true); grid.add(signedTxTxt, 0, 1); // Display some info about Transaction after sent Text txInfo = new Text(); grid.add(txInfo, 0, 4); // Add Next Button Button nextBtn = new Button("Send Transaction"); nextBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Transaction signedTx = new Transaction(); Transaction.deserializeStr(signedTxTxt.getText(), signedTx); txInfo.setText("Transaction being broadcast. TXID: " + signedTx.getHash() + "\nPlease wait a few minutes for best results, but you may now exit."); Broadcaster.broadcastTransaction(Transaction.serialize(signedTx, false)); } }); 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("Exit"); cancelBtn.setOnAction(cancelEvent); btnHbox.getChildren().add(cancelBtn); grid.add(btnHbox, 0, 2); return grid; }