* row.
* <p>
* If the last row is removed then all remaining components will be removed
- * and the grid will be reduced to one row and one column.
+ * and the grid will be reduced to one row. The cursor will be moved to the
+ * upper left cell of the grid.
* </p>
*
* @param row
if (rows == 1) {
/*
* Removing the last row means that the dimensions of the Grid
- * layout will be truncated to 1x1 and all components removed.
+ * layout will be truncated to 1 empty row and the cursor is moved
+ * to the first cell
*/
- setColumns(1);
+ cursorX = 0;
cursorY = 0;
} else {
setRows(rows - 1);
fail("removeRow(0) threw an IllegalArgumentExcetion when removing the last row");
}
- // The grid should now be empty with one row and one column
- assertEquals(1, grid.getColumns());
+ // The column amount should be preserved
+ assertEquals(2, grid.getColumns());
+
+ // There should be one row left
assertEquals(1, grid.getRows());
// There should be no component left in the grid layout
assertNull("A component should not be left in the layout", grid
.getComponent(0, 0));
+ assertNull("A component should not be left in the layout", grid
+ .getComponent(1, 0));
+
+ // The cursor should be in the first cell
+ assertEquals(0, grid.getCursorX());
+ assertEquals(0, grid.getCursorY());
}
}