/** * Adds the connections between two boxes. * * @param nameBox1 Name of the upper box. * @param nameBox2 Name of the lower box. */ public void addConnection(String nameBox1, String nameBox2) { for (Box box1 : this.boxes) { if (box1.getName().equals(nameBox1)) { for (Box box2 : this.boxes) { if (box2.getName().equals(nameBox2)) { box1.addBoxUnder(box2); box2.addBoxAbove(box1); } } } } }