void (final JCheckBox checkbox, final JComponent component) { final Runnable runnable = () -> getGlobalInstance().doWhenFocusSettlesDown(() -> getGlobalInstance().requestFocus(component, true)); checkbox.addActionListener(e -> { if (checkbox.isSelected()) { SwingUtilities.invokeLater(runnable); } }); }