Advertisement
Oslapas

Untitled

Feb 11th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3.  
  4. import javafx.scene.Node;
  5. import javafx.scene.layout.GridPane;
  6.  
  7. public class SpecialGridPane extends GridPane {
  8.     List<NodeParent> list = new ArrayList<>();
  9.  
  10.     public void addChild(int row, int column, Node node) {
  11.         list.add(new NodeParent(row, column, node));
  12.         setConstraints(node, column, row);
  13.         getChildren().add(node);
  14.     }
  15.  
  16.     public Node getChild(int row, int column) {
  17.         for (NodeParent node : list) {
  18.             if (node.getRow() == row && node.getColumn() == column)
  19.                 return node.getNode();
  20.         }
  21.         return null;
  22.     }
  23. }
  24.  
  25. class NodeParent {
  26.     private int row;
  27.     private int column;
  28.     private Node node;
  29.  
  30.     public NodeParent(int row, int column, Node node) {
  31.         this.row = row;
  32.         this.column = column;
  33.         this.node = node;
  34.     }
  35.  
  36.     public int getRow() {
  37.         return row;
  38.     }
  39.  
  40.     public int getColumn() {
  41.         return column;
  42.     }
  43.  
  44.     public Node getNode() {
  45.         return node;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement