void () { myTree.registerKeyboardAction( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performEnterAction(true); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_FOCUSED ); new DoubleClickListener() { @Override protected boolean onDoubleClick(@NotNull MouseEvent e) { performEnterAction(false); return true; } }.installOn(myTree); }