void (final JComponent component) { if (component instanceof JTextField field) { String text = field.getText(); if (text != null && field.getClientProperty(HAVE_INITIAL_SELECTION) == null) { field.setSelectionStart(0); field.setSelectionEnd(text.length()); } } else if (component instanceof JComboBox) { ((JComboBox<?>)component).getEditor().selectAll(); } }