void () { myMacrosList.getSelectionModel().addListSelectionListener( e -> { Item item = myMacrosList.getSelectedValue(); if (item == null) { myPreviewTextarea.setText(""); setOKActionEnabled(false); } else { myPreviewTextarea.setText(item.getPreview()); setOKActionEnabled(true); } } ); new DoubleClickListener() { @Override protected boolean onDoubleClick(@NotNull MouseEvent e) { if (getSelectedMacroName() != null) { close(OK_EXIT_CODE); return true; } return false; } }.installOn(myMacrosList); }