void (KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return; boolean up = e.getKeyCode() == KeyEvent.VK_UP; try { float value = Float.parseFloat(myEditorFontSizeField.getText()); value += (up ? 1 : -1); value = MathUtil.clamp(value, EditorFontsConstants.getMinEditorFontSize(), EditorFontsConstants.getMaxEditorFontSize()); myEditorFontSizeField.setText(String.valueOf(value)); } catch (NumberFormatException ignored) { } }