void (ActionEvent e) { Object text = myMacroList.getSelectedValue(); if (text != null) { String macroName = text.toString(); int pos = macroName.indexOf(" - "); if (pos >= 0) { macroName = macroName.substring(0, pos); } try { myURLPatternTextField.getDocument().insertString(myURLPatternTextField.getCaretPosition(), macroName, null); } catch (BadLocationException ignored) { } } }