public Node getNodeByRowColumnIndex (final int row, final int column, GridPane gridPane) { Node result = null; ObservableList<Node> childrens = gridPane.getChildren(); for (Node node : childrens) { if(gridPane.getRowIndex(node) == row && gridPane.getColumnIndex(node) == column) { result = node; break; } } return result; }
public void updateSelection(Color color) { setFocusedSquare(null); for (ColorSquare c : colorPickerGrid.getSquares()) { if (c.rectangle.getFill().equals(color)) { setFocusedSquare(c); return; } } // check custom colors for (Node n : customColorGrid.getChildren()) { ColorSquare c = (ColorSquare) n; if (c.rectangle.getFill().equals(color)) { setFocusedSquare(c); return; } } }
private FilteredList<Node> inRow(RowConstraints row) { final int index = grid.getRowConstraints().indexOf(row); return grid.getChildren() .filtered(node -> { final Integer rowIndex = GridPane.getRowIndex(node); return rowIndex != null && index == GridPane.getRowIndex(node); }); }
void updateContentGrid() { contentGrid.getColumnConstraints().clear(); contentGrid.getChildren().clear(); int colsNumber = daysPerWeek + (datePicker.isShowWeekNumbers() ? 1 : 0); ColumnConstraints columnConstraints = new ColumnConstraints(); columnConstraints.setPercentWidth(100); for (int i = 0; i < colsNumber; i++) { contentGrid.getColumnConstraints().add(columnConstraints); } // Week days cells for (int i = 0; i < daysPerWeek; i++) { contentGrid.add(weekDaysCells.get(i), i + colsNumber - daysPerWeek, 1); } // Week number cells if (datePicker.isShowWeekNumbers()) { for (int i = 0; i < 6; i++) { contentGrid.add(weekNumberCells.get(i), 0, i + 2); } } // Month days cells for (int row = 0; row < 6; row++) { for (int col = 0; col < daysPerWeek; col++) { contentGrid.add(dayCells.get(row * daysPerWeek + col), col + colsNumber - daysPerWeek, row + 2); } } }
private Node getNodeFromGridPane(GridPane gridPane, int col, int row) { for (Node node : gridPane.getChildren()) { if (GridPane.getColumnIndex(node) == col && GridPane.getRowIndex(node) == row) { return node; } } return null; }
private void buildCustomColors() { final ObservableList<Color> customColors = colorPicker.getCustomColors(); customColorGrid.getChildren().clear(); if (customColors.isEmpty()) { customColorLabel.setVisible(false);
private StackPane getCenteredNodeGridPane(GridPane gridPane, int col, int row) { for (Node node : gridPane.getChildren()) { if (node instanceof StackPane && GridPane.getColumnIndex(node) == col/2 && GridPane.getRowIndex(node) == row/2) { return (StackPane) node; } } return null; }
public TextArea getNodeByRowColumnIndex( final int row, final int column, GridPane gridPane) { ObservableList<Node> childrens = gridPane.getChildren(); TextArea result = (TextArea) childrens.get((row*3)+column); return result; }
private int getRowCount(GridPane pane) { int numRows = pane.getRowConstraints().size(); for (int i = 0; i < pane.getChildren().size(); i++) { Node child = pane.getChildren().get(i); if (child.isManaged()) { Integer rowIndex = GridPane.getRowIndex(child); if(rowIndex != null){ numRows = Math.max(numRows,rowIndex+1); } } } return numRows; }
GridPane root = new GridPane(); for (int x = 0 ; x < 8; x++) { for (int y = 0 ; y < 8 ; y++) { Label label = new Label(String.format("Cell [%d, %d]", x, y)); root.getChildren().add(label); GridPane.setColumnIndex(label, x); GridPane.setRowIndex(label, y); } }
/** * Displays the current {@link SnapshotView#nodeProperty() node}. */ private void updateNode() { if (node != null) { gridPane.getChildren().remove(node); } node = getSkinnable().getNode(); if (node != null) { gridPane.getChildren().add(0, node); } }
GridPane root = new GridPane(); for (int x = 0 ; x < 8; x++) { for (int y = 0 ; y < 8 ; y++) { Label label = new Label(String.format("Cell [%d, %d]", x, y)); root.getChildren().add(label); label.getProperties().put("gridpane-column", new Integer(x)); label.getProperties().put("gridpane-row", new Integer(y)); } }
public Node getNodeByRowColumnIndex(final int row,final int column,GridPane gridPane) { Node result = null; ObservableList<Node> childrens = gridPane.getChildren(); for(Node node : childrens) { if(gridPane.getRowIndex(node) == row && gridPane.getColumnIndex(node) == column) { result = node; break; } } return result; }
@Override public void handle(final MouseEvent event) { label.setText(""); grid.getChildren().remove(imgView); if (isYaml) { setSwitchBatchSelected(false); } } });
ObservableMap<Point, Sheep> allSheep = FXCollections.observableHashMap(); GridPane gameView = new GridPane(); allSheep.addListener((Change<? extends Point, ? extends Sheep> c) -> { if (c.wasAdded()) { Point location = c.getKey(); Sheep addedSheep = c.getValue(); gameView.add(addedSheep.getView(), location.x, location.y); } else if (c.wasRemoved()) { Sheep removedSheep = c.getValue(); gameView.getChildren().remove(removedSheep.getView()); } }
public Node getNodeByRowColumnIndex(final int row,final int column,GridPane gridPane) { Node result = null; ObservableList<Node> childrens = gridPane.getChildren(); for(Node node : childrens) { if(node instanceof Circle && gridPane.getRowIndex(node) == row && gridPane.getColumnIndex(node) == column) { result = node; break; } } return result; }
GridPane grid = new GridPane(); Label first = new Label("first"); Label second = new Label("second"); grid.add(first, 1, 1); grid.add(second, 2, 2); second.setOnMouseClicked(e -> { grid.getChildren().remove(second); grid.add(new Label("last"), 2, 2); }); box.getChildren().addAll(grid);
public void start(Stage primaryStage) { GridPane pane = new GridPane(); GraphFunc test = new GraphFunc(); test.setPrefSize(500, 500); pane.getChildren().add(test); Scene scene = new Scene(pane); primaryStage.setScene(scene); primaryStage.show(); }
public void add(Node labelNode, Node dataNode) { GridPane.setConstraints(labelNode, 0, rowCount); GridPane.setConstraints(dataNode, 1, rowCount); GridPane.setHgrow(labelNode, Priority.SOMETIMES); GridPane.setHgrow(dataNode, Priority.ALWAYS); GridPane.setHalignment(labelNode, HPos.RIGHT); GridPane.setHalignment(dataNode, HPos.LEFT); mainPane.getChildren().addAll(labelNode, dataNode); rowCount++; }
public void add(Node labelNode, Node dataNode) { GridPane.setConstraints(labelNode, 0, rowCount); GridPane.setConstraints(dataNode, 1, rowCount); GridPane.setHgrow(labelNode, Priority.SOMETIMES); GridPane.setHgrow(dataNode, Priority.ALWAYS); GridPane.setHalignment(labelNode, HPos.RIGHT); GridPane.setHalignment(dataNode, HPos.LEFT); mainPane.getChildren().addAll(labelNode, dataNode); rowCount++; }