void (@NotNull JSpinner spinner) { JSpinner.DefaultEditor editor = ObjectUtils.tryCast(spinner.getEditor(), JSpinner.DefaultEditor.class); if (editor == null) return; JFormattedTextField field = editor.getTextField(); field.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), INCREASE_NUMBER_ID); field.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), DECREASE_NUMBER_ID); field.getActionMap().put(INCREASE_NUMBER_ID, getIncAction(spinner, field, 1)); field.getActionMap().put(DECREASE_NUMBER_ID, getIncAction(spinner, field, -1)); }