@Override public void start(Stage primaryStage) throws Exception { Label fnameLbl = new Label(Msg.get(this, "firstName")); TextField fnameFld = new TextField(); Label lnameLbl = new Label(Msg.get(this, "lastName")); TextField lnameFld = new TextField(); Button okBtn = new Button(Msg.get(this, "OK")); Button cancelBtn = new Button(Msg.get(this, "cancel")); // The OK button should fill its cell okBtn.setMaxWidth(Double.MAX_VALUE); // Create a GridPane and set its background color to lightgray GridPane root = new GridPane(); root.setGridLinesVisible(true); root.setHgap(10); root.setVgap(5); root.setStyle(Msg.get(this, "style")); // Add children to teh GridPane root.addRow(0, fnameLbl, fnameFld, okBtn); root.addRow(1, lnameLbl, lnameFld, cancelBtn); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.setTitle(Msg.get(this, "title")); primaryStage.show(); }
public void init() { dob.setPrefWidth(200); GridPane grid = new GridPane(); grid.addRow(0, new Label("First Name:"), firstNameFld); grid.addRow(1, new Label("Last Name:"), lastNameFld); grid.addRow(2, new Label("DOB:"), dob); this.setContent(grid); }
public void makeBoard(Cell[][] cells) { if (stageGridPane != null) { // Устанавливаем размер клетки stageGridPane.getColumnConstraints().add(new ColumnConstraints(10)); stageGridPane.getRowConstraints().add(new RowConstraints(10)); if (cells[0][0] == null) { fillCircuit(); } // Заполняем массив клеток основного поля и выводим его на экран for (int i = 1; i < cells.length - 1; i++) { stageGridPane.addRow(i); for (int j = 1; j < cells[0].length - 1; j++) { stageGridPane.addColumn(j); Cell tempRect = new Cell(10, 10, Color.WHITE, i, j); if (cells[i][j] == null) { stageGridPane.add(cells[i][j] = tempRect, i, j); } else { if (cells[i][j].isRoad) { cells[i][j].setFill(Color.BLUE); } } cells[i][j].setStroke(Color.BLACK); cells[i][j].setOnMouseClicked( t -> { switch (CellType.getValue()) { case "Wall": if (tempRect.getFill() == Color.BLACK) { tempRect.setFill(Color.WHITE); tempRect.isBlocked = false; } else { tempRect.setFill(Color.BLACK); tempRect.isBlocked = true; } break; case "Start": if (tempRect.getFill() == Color.GREEN) { tempRect.setFill(Color.WHITE); start = null; } else if (start == null) { tempRect.setFill(Color.GREEN); start = tempRect; } break; case "End": if (tempRect.getFill() == Color.RED) { tempRect.setFill(Color.WHITE); finish = null; } else if (finish == null) { tempRect.setFill(Color.RED); finish = tempRect; } break; } }); } } } else { System.err.print("stageGridPane is null"); } }
public void redrawMacroGridPane() { // Remove all nodes except first row ObservableList<Node> children = macroGridPane.getChildren(); for (ListIterator<Node> iter = children.listIterator(); iter.hasNext(); ) { Node node = iter.next(); if (GridPane.getRowIndex(node) != 0) { iter.remove(); } } // Repopulate GridPane with macro rows for (Macro macro : terminal.txRx.macroManager.macros) { MacroRow macroRow = new MacroRow(model, terminal, macro, glyphFont); macroGridPane.addRow( GridPaneHelper.getNumRows(macroGridPane), macroRow.nameTextField, macroRow.sequenceTextField, macroRow.runButton); } }
private void buildUserCredentials(ActionEvent event) { // System.out.println("Valore di numreserved " + Integer.toString(numreserved)); GridPane gp = ((GridPane) ((Button) event.getSource()).getParent()); int numreserved = ((Spinner<Integer>) gp.getChildren().get(0)).getValue(); gridCredential.getChildren().clear(); /* int j =0; for(int i=0; i<numreserved*3;i = i + 3){ Label nameL = new Label("Nome partecipante"); Label surnameL = new Label("Cognome partecipante"); Label birthdayL = new Label("Data Nascita"); TextField txname = new TextField(); TextField txsurname = new TextField(); TextField txbirthday = new TextField(); gridCredential.add(nameL,j,i); gridCredential.add(txname,j+1,i); gridCredential.add(surnameL,j,i+1); gridCredential.add(txsurname,j+1,i+1); gridCredential.add(birthdayL,j,i+2); gridCredential.add(txbirthday,j+1,i+2); gridCredential.setVgap(20); gridCredential.setHgap(3); }*/ for (int i = 0; i < numreserved; i++) { GridPane grd = new GridPane(); Label lblL = new Label("Inserire credenziali partecipante"); Label nameL = new Label("Nome partecipante"); Label surnameL = new Label("Cognome partecipante"); Label birthdayL = new Label("Data Nascita"); TextField txname = new TextField(); TextField txsurname = new TextField(); TextField txbirthday = new TextField(); grd.add(lblL, 0, 0); grd.addRow(1); grd.add(nameL, 0, 2); grd.add(txname, 1, 2); grd.add(surnameL, 0, 3); grd.add(txsurname, 1, 3); grd.add(birthdayL, 0, 4); grd.add(txbirthday, 1, 4); grd.addRow(5); grd.setVgap(10); grd.setHgap(3); gridCredential.add(grd, 0, i); } Button okButton = new Button("OK"); gridCredential.add(okButton, 0, numreserved); okButton.setId(((RadioButton) tg.getSelectedToggle()).getId()); okButton.setOnAction(prenotaViaggioControl::reserveTrip); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(gridCredential); gp.add(scrollPane, 0, 1); gpMediator.send(gridCredential, this); }
private Pane createORCADatePane(double spacing) { final char degree = 176; final String temperatureMsg = "Temperature: "; Label temperatureLabel = new Label(); temperatureLabel .textProperty() .bindBidirectional( orca.temperatureProperty(), new DecimalFormat(temperatureMsg + "##.####" + degree)); ProgressBar temperatureBar = new ProgressBar(); temperatureBar.progressProperty().bindBidirectional(orca.temperatureProperty()); final String batteryTemperatureMsg = "Battery Temperature: "; Label batteryTemperatureLabel = new Label(); batteryTemperatureLabel .textProperty() .bindBidirectional( orca.batteryTemperatureProperty(), new DecimalFormat(batteryTemperatureMsg + "##.####" + degree)); ProgressBar batteryTemperatureBar = new ProgressBar(); batteryTemperatureBar.progressProperty().bind(orca.batteryTemperatureProperty()); final String batteryVoltageMsg = "Battery Voltage: "; Label batteryVoltageLabel = new Label(); batteryVoltageLabel .textProperty() .bindBidirectional( orca.batteryVoltageProperty(), new DecimalFormat(batteryVoltageMsg + "##.#### V")); ProgressBar batteryVoltageBar = new ProgressBar(); batteryVoltageBar.progressProperty().bindBidirectional(orca.batteryVoltageProperty()); String directionMsg = "Direction: "; Label directionLabel = new Label(); directionLabel .textProperty() .bindBidirectional( orca.directionProperty(), new DecimalFormat(directionMsg + "##.####" + degree)); String rotationsPerSecondMsg = "Rotations Per Second: "; Label rotationsPerSecondLabel = new Label(); rotationsPerSecondLabel .textProperty() .bindBidirectional( orca.rotationsPerSecondProperty(), new DecimalFormat(rotationsPerSecondMsg + "###.#### rpms")); String metersPerSecondMsg = "Meters Per Second: "; Label metersPerSecondLabel = new Label(); metersPerSecondLabel .textProperty() .bindBidirectional( orca.metersPerSecondProperty(), new DecimalFormat(metersPerSecondMsg + "###.#### mps")); GridPane orcaDataPane = new GridPane(); orcaDataPane.setHgap(spacing); orcaDataPane.setVgap(spacing); orcaDataPane.addRow(0, directionLabel); orcaDataPane.addRow(1, rotationsPerSecondLabel); orcaDataPane.addRow(2, metersPerSecondLabel); orcaDataPane.addRow(3, temperatureLabel, temperatureBar); orcaDataPane.addRow(4, batteryTemperatureLabel, batteryTemperatureBar); orcaDataPane.addRow(5, batteryVoltageLabel, batteryVoltageBar); return orcaDataPane; }
public BigDecimalFieldSample() { GridPane root = new GridPane(); root.setHgap(10); root.setVgap(10); root.setPadding(new Insets(10, 10, 10, 10)); final BigDecimalField defaultSpinner = new BigDecimalField(); defaultSpinner.getStyleClass().add("bigDecimalField"); final BigDecimalField decimalFormat = new BigDecimalField(BigDecimal.ZERO, new BigDecimal("0.05"), new DecimalFormat("#,##0.00")); decimalFormat.getStyleClass().add("bigDecimalField"); final BigDecimalField percent = new BigDecimalField( BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getPercentInstance()); percent.getStyleClass().add("bigDecimalField"); final BigDecimalField localizedCurrency = new BigDecimalField( BigDecimal.ZERO, new BigDecimal("0.01"), NumberFormat.getCurrencyInstance(Locale.UK)); localizedCurrency.getStyleClass().add("bigDecimalField"); root.addRow(1, new Label("default"), defaultSpinner); root.addRow(2, new Label("custom decimal format"), decimalFormat); root.addRow(3, new Label("percent"), percent); root.addRow(4, new Label("localized currency"), localizedCurrency); root.addRow( 5, new Label("normal TextField"), TextFieldBuilder.create().text("1.000,12").styleClass("bigDecimalField").build()); final ChoiceBox styles = new ChoiceBox( FXCollections.observableArrayList( "rectangular corners - small font", "rounded corners - medium font", "leaf corners - large font")); styles .getSelectionModel() .selectedIndexProperty() .addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { System.out.println("index" + arg2.intValue()); Scene scene = styles.getScene(); String pathSquared = BigDecimalFieldSample.class .getResource("BigDecimalField_squared.css") .toExternalForm(); String pathRounded = BigDecimalFieldSample.class .getResource("BigDecimalField_rounded.css") .toExternalForm(); String pathLeaf = BigDecimalFieldSample.class .getResource("BigDecimalField_leaf.css") .toExternalForm(); scene.getStylesheets().removeAll(pathSquared, pathRounded, pathLeaf); if (arg2.intValue() == 0) { scene.getStylesheets().add(pathSquared); } if (arg2.intValue() == 1) { scene.getStylesheets().add(pathRounded); } if (arg2.intValue() == 2) { scene.getStylesheets().add(pathLeaf); } } }); root.addRow(6, new Label("change css"), styles); Button button = new Button("Reset fields"); button.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { defaultSpinner.setNumber(new BigDecimal(Math.random() * 1000)); decimalFormat.setNumber(new BigDecimal(Math.random() * 1000)); percent.setNumber(new BigDecimal(Math.random())); localizedCurrency.setNumber(new BigDecimal(Math.random() * 1000)); // disabledField.setNumber(new BigDecimal(Math.random() * 1000)); } }); root.addRow(7, new Label(), button); getChildren().add(root); }