Grid extends JPanel implements GridSelectionModel.Listener { public void removeDataRow(int dataRowIndex) { Assert.argument(dataRowIndex >= 0, "dataRowIndex"); int rowIndex = dataRowIndex + 1; removeFiller(); boolean rowSelected = isDataRowSelected(rowIndex); List<JComponent> componentRow = componentRows.get(rowIndex); removeComponentRowIntern(componentRow); componentRows.remove(rowIndex); for (int i = rowIndex; i < componentRows.size(); i++) { addComponentRowIntern(componentRows.get(i), i); } addFiller(); fireComponentsChanged(); if (rowSelected) { selectionModel.removeSelectedRowIndex(dataRowIndex); } } Grid(int columnCount, boolean showSelectionColumn);  Grid(TableLayout tableLayout, boolean showSelectionColumn); @Override TableLayout getLayout(); @Override void setLayout(LayoutManager mgr); GridSelectionModel getSelectionModel(); void setSelectionModel(GridSelectionModel selectionModel); boolean getShowSelectionColumn(); void setShowSelectionColumn(boolean showSelectionColumn); int getColumnCount(); int getDataColumnCount(); int getRowCount(); int getDataRowCount(); JComponent getComponent(int rowIndex, int colIndex); JComponent setComponent(int rowIndex, int colIndex, JComponent component); int findRowIndex(JComponent component); int findDataRowIndex(JComponent component); void setHeaderRow(JComponent... components); JComponent[] getDataRow(int dataRowIndex); void addDataRow(JComponent... components); void removeDataRow(int dataRowIndex); void removeDataRows(int... dataRowIndexes); void moveDataRowUp(int dataRowIndex); void moveDataRowDown(int dataRowIndex); boolean isDataRowSelected(int dataRowIndex); int getSelectedDataRowCount(); int getSelectedDataRowIndex(); int[] getSelectedDataRowIndexes(); void setSelectedDataRowIndexes(int... dataRowIndexes); @Override void gridSelectionChanged(GridSelectionModel.Event event);  }
@Test public void testRemoveDataRow() throws Exception { Grid grid = new Grid(4, true); JLabel c1 = new JLabel(); JLabel c2 = new JLabel(); JLabel c3 = new JLabel(); JLabel c4 = new JLabel(); JLabel c5 = new JLabel(); JLabel c6 = new JLabel(); grid.addDataRow(c1, c2, c3); grid.addDataRow(c4, c5, c6); grid.removeDataRow(0); assertEquals(1, grid.getDataRowCount()); assertEquals(2, grid.getRowCount()); assertEquals(JCheckBox.class, grid.getComponent(1, 0).getClass()); assertSame(c4, grid.getComponent(1, 1)); assertSame(c5, grid.getComponent(1, 2)); assertSame(c6, grid.getComponent(1, 3)); grid.removeDataRow(0); assertEquals(0, grid.getDataRowCount()); assertEquals(1, grid.getRowCount()); }