boolean () { final var c = getContextComponent(); if (c instanceof JTable || c instanceof JList) { final ListSelectionModel model = c instanceof JTable ? ((JTable)c).getSelectionModel() : ((JList<?>)c).getSelectionModel(); final int size = c instanceof JTable ? ((JTable)c).getRowCount() : ((JList<?>)c).getModel().getSize(); final int min = model.getMinSelectionIndex(); final int max = model.getMaxSelectionIndex(); return isEnabled(size, min, max); } else { return true; } }