boolean (final ComponentDragObject dragObject, boolean isRow) { if (dragObject.getComponentCount() == 0) { return true; } int cell = isRow ? dragObject.getRelativeRow(0) : dragObject.getRelativeCol(0); for(int i=1; i<dragObject.getComponentCount(); i++) { int cell2 = isRow ? dragObject.getRelativeRow(i) : dragObject.getRelativeCol(i); if (cell2 != cell) { return false; } } return true; }