void () { myNameBox.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { myNameBox.getEditor().selectAll(); } }); myValueField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { myValueField.selectAll(); } }); }