void (CaptionSelection selection) { FormLayout layout = (FormLayout) selection.getContainer().getLayout(); int[][] oldGroups = selection.isRow() ? layout.getRowGroups() : layout.getColumnGroups(); List<int[]> newGroups = new ArrayList<>(); int[] selInts = selection.getSelection(); for(int[] group: oldGroups) { if (!GroupRowsColumnsAction.intersect(group, selInts)) { newGroups.add(group); } } int[][] newGroupArray = newGroups.toArray(new int[newGroups.size()][]); if (selection.isRow()) { layout.setRowGroups(newGroupArray); } else { layout.setColumnGroups(newGroupArray); } }