@Override public void keyReleased(KeyEvent e){
  if (lastPressedKey != e.getKeyCode()) {
    e.consume();
    return;
  }
  lastPressedKey=0;
  if (e.getModifiers() == 0) {
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
case KeyEvent.VK_SPACE:
      TreePath path=getSelectionPath();
    if (path == null) {
      return;
    }
  Entry entry=(Entry)path.getLastPathComponent();
if (entry instanceof Folder) {
  if (isExpanded(path)) {
    collapsePath(path);
  }
 else {
    expandPath(path);
  }
}
 else {
  fireLocationSelected((Entry)path.getLastPathComponent());
}
e.consume();
break;
}
}
}

@ Override public void keyReleased ( KeyEvent e ) { if ( lastPressedKey != e . getKeyCode ( ) ) { e . consume ( ) ; return ; } lastPressedKey = 0 ; if ( e . getModifiers ( ) == 0 ) { switch ( e . getKeyCode ( ) ) { case KeyEvent . VK_ENTER : case KeyEvent . VK_SPACE : TreePath path = getSelectionPath ( ) ; if ( path == null ) { return ; } Entry entry = ( Entry ) path . getLastPathComponent ( ) ; if ( entry instanceof Folder ) { if ( isExpanded ( path ) ) { collapsePath ( path ) ; } else { expandPath ( path ) ; } } else { fireLocationSelected ( ( Entry ) path . getLastPathComponent ( ) ) ; } e . consume ( ) ; break ; } } }
opens entries on enter pressed ; collapses / expands folders
