JComponent () { myTree = initTree(); myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { doOKAction(); } } }); new DoubleClickListener() { @Override protected boolean onDoubleClick(@NotNull MouseEvent e) { if (mySelectedTarget != null) { doOKAction(); return true; } return false; } }.installOn(myTree); return JBUI.Panels.simplePanel(ScrollPaneFactory.createScrollPane(myTree)); }