TextField firstNameFld = new TextField(); firstNameFld.setPrefColumnCount(8); TextField lastNameFld = new TextField(); lastNameFld.setPrefColumnCount(8); GridPane grid = new GridPane(); grid.addRow(0, new Label("First Name:"), firstNameFld); grid.addRow(1, new Label("Last Name:"), lastNameFld); tp1.setContent(grid); tp2.setContent(new Label("tp2.............")); tp3.setContent(new Label("tp3.............."));
@Override public void start(Stage primaryStage) { GridPane root = new GridPane(); root.addRow(0, new Circle(50, Color.GREEN), new Circle(50, Color.YELLOW), new Circle(50, Color.RED)); root.addRow(1, new Rectangle(50, 50), new Rectangle(50, 50), new Rectangle(50, 50)); Board board = new Board(root); EventHandler<MouseEvent>[] handlers = new EventHandler[] { board.new CircleEventHandler(), board.new RectangleEventHandler() }; for (Node n : root.getChildren()) { n.setOnMouseClicked(handlers[GridPane.getRowIndex(n)]); } Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.show(); }
@Override public void start(Stage primaryStage) { GridPane chat = new GridPane(); chat.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); ColumnConstraints c1 = new ColumnConstraints(); c1.setPercentWidth(100); chat.getColumnConstraints().add(c1); for (int i = 0; i < 20; i++) { Label chatMessage = new Label("Hi " + i); chatMessage.getStyleClass().add("chat-bubble"); GridPane.setHalignment(chatMessage, i % 2 == 0 ? HPos.LEFT : HPos.RIGHT); chat.addRow(i, chatMessage); } ScrollPane scroll = new ScrollPane(chat); scroll.setFitToWidth(true); Scene scene = new Scene(scroll, 500, 500); scene.getStylesheets().add(getClass().getResource("Test.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); }
/** * Adds the category input to the given {@link GridPane} * * @param gridPane The grid pane to which the category input should be added * @return The {@link TextField} containing the category */ private TextField addCategory(final GridPane gridPane) { final int row = gridPane.getRowCount(); final Label categoryLabel = new Label(tr("Category:")); categoryLabel.getStyleClass().add("captionTitle"); GridPane.setValignment(categoryLabel, VPos.TOP); final TextField category = new TextField(); gridPane.addRow(row, categoryLabel, category); return category; }
/** * Adds the description input to the given {@link GridPane} * * @param gridPane The grid pane to which the description input should be added * @return The {@link TextArea} containing the description */ private TextArea addDescription(final GridPane gridPane) { final int row = gridPane.getRowCount(); final Label descriptionLabel = new Label(tr("Description:")); descriptionLabel.getStyleClass().add("captionTitle"); GridPane.setValignment(descriptionLabel, VPos.TOP); final TextArea description = new TextArea(); gridPane.addRow(row, descriptionLabel, description); return description; }
/** * Adds the shortcut name input to the given {@link GridPane} * * @param gridPane The grid pane to which the shortcut name input should be added * @return The {@link TextField} containing the shortcut name */ private TextField addName(final GridPane gridPane) { final int row = gridPane.getRowCount(); final Label nameLabel = new Label(tr("Name:")); nameLabel.getStyleClass().add("captionTitle"); GridPane.setValignment(nameLabel, VPos.TOP); final TextField name = new TextField(); gridPane.addRow(row, nameLabel, name); return name; }
/** * Updates the shortcutProperties of the shortcut in the given {@link GridPane propertiesGrid} * * @param propertiesGrid The shortcutProperties grid */ private void updateProperties(final GridPane propertiesGrid) { propertiesGrid.getChildren().clear(); for (Map.Entry<String, Object> entry : shortcutProperties.entrySet()) { final int row = propertiesGrid.getRowCount(); final Label keyLabel = new Label(tr(decamelize(entry.getKey())) + ":"); keyLabel.getStyleClass().add("captionTitle"); GridPane.setValignment(keyLabel, VPos.TOP); final Label valueLabel = new Label(entry.getValue().toString()); valueLabel.setWrapText(true); propertiesGrid.addRow(row, keyLabel, valueLabel); } }
private Color color = Color.BLACK; @Override public void start(Stage primaryStage) { GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Button btn = new Button("Add Rect"); // add node specifying column and row index gridPane.add(btn, 0, 0); gridPane.setStyle("-fx-background-color: lime;"); btn.setOnAction((ActionEvent event) -> { color = color.brighter(); Rectangle rectangle = new Rectangle(20, 20); rectangle.setFill(color); // append rect to second row gridPane.addRow(1, rectangle); }); Scene scene = new Scene(gridPane, 500, 500); primaryStage.setScene(scene); primaryStage.show(); }
/** * Updates the user data of the selected engine in the given {@link GridPane userDataGrid} * * @param userDataGrid The user data grid */ private void updateUserData(final GridPane userDataGrid) { userDataGrid.getChildren().clear(); final Text versionLabel = new Text(tr("Version:")); versionLabel.getStyleClass().add("captionTitle"); final Label name = new Label(); name.textProperty().bind(engineVersionName); name.setWrapText(true); userDataGrid.addRow(0, versionLabel, name); for (Map.Entry<String, String> userData : engineUserData.entrySet()) { final int row = userDataGrid.getRowCount(); final Text userDataLabel = new Text(tr(userData.getKey())); userDataLabel.getStyleClass().add("captionTitle"); final Label path = new Label(userData.getValue()); path.setWrapText(true); userDataGrid.addRow(row, userDataLabel, path); } }
public void start(Stage stage) { VBox box1 = new VBox(1); VBox box2 = new VBox(1); //random content RectangleBuilder builder = RectangleBuilder.create().width(20).height(20); box1.getChildren().addAll(builder.build(), builder.build(), builder.build()); builder.fill(Color.RED); box2.getChildren().addAll(builder.build(), builder.build(), builder.build()); //half by half screen GridPane grid = new GridPane(); grid.addRow(0, box1, box2); ColumnConstraints halfConstraint = ColumnConstraintsBuilder.create().percentWidth(50).build(); grid.getColumnConstraints().addAll(halfConstraint, halfConstraint); stage.setScene(new Scene(grid, 300, 250)); stage.show(); }
imagePane.getRowConstraints().add(rowConstraints); imagePane.addRow(currentRow, newImage); nextColumnIndex++; });
gridPane.addRow(row, executableLabel, executableHbox);
gridPane.addRow(row, miniatureLabel, miniatureHbox);
root.addRow(0, ipAdd1, ipAdd2, ipAdd3, ipAdd4);
private void addNewInputBinding(UserAction action, Trigger trigger, GridPane grid) { Text actionName = getUIFactory().newText(action.getName(), Color.WHITE, 18.0); TriggerView triggerView = new TriggerView(trigger); triggerView.triggerProperty().bind(app.getInput().triggerProperty(action)); triggerView.setOnMouseClicked(event -> { pressAnyKeyState.actionContext = action; FXGL.getStateMachine().pushState(pressAnyKeyState); }); HBox hBox = new HBox(); hBox.setPrefWidth(100); hBox.setAlignment(Pos.CENTER); hBox.getChildren().add(triggerView); int controlsRow = (int) grid.getUserData(); grid.addRow(controlsRow++, actionName, hBox); grid.setUserData(controlsRow); }
buttons.addRow(1, plus, eval);
/** * Refreshes the shown scripts. * When this method is called it begins by clearing the <code>scriptGrid</code>. * Afterwards this method refills it. */ private void updateScripts(final GridPane scriptGrid) { scriptGrid.getChildren().clear(); for (int i = 0; i < filteredScripts.size(); i++) { ScriptDTO script = filteredScripts.get(i); final Label scriptName = new Label(script.getScriptName()); GridPane.setHgrow(scriptName, Priority.ALWAYS); if (getControl().isShowScriptSource()) { final Tooltip tooltip = new Tooltip(tr("Source: {0}", script.getScriptSource())); Tooltip.install(scriptName, tooltip); } final Button installButton = new Button(tr("Install")); installButton.setOnMouseClicked(evt -> { try { installScript(script); } catch (IllegalArgumentException e) { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error while trying to download the installer")) .withException(e) .build(); errorDialog.showAndWait(); } }); scriptGrid.addRow(i, scriptName, installButton); } }