static void tableDependButtons(JTable table, L buttons) { for (Component c : buttons) if (c instanceof JButton) { JButton b = cast c; onTableSelectionChangedAndNow(table, -> b.setEnabled(table.getSelectedRow() >= 0)); } }