void (@NotNull JSpinner spinner) { JSpinner.DefaultEditor editor = ObjectUtils.tryCast(spinner.getEditor(), JSpinner.DefaultEditor.class); if (editor == null) return; editor.getTextField().addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { ApplicationManager.getApplication().invokeLater(() -> { editor.getTextField().selectAll(); }); } @Override public void focusLost(FocusEvent e) { } }); }