Editable JTree & KeyEvent

  • Follow


I can edit values in a JTree by right clicking and selecting rename (I
wrote the pop-up menu).  This works fine.  But, when I hit [Enter] to
set the new name (which is captured by editingStopped(ChangeEvent) of
the CellEditorListener), not only does the new name get set, but, the
KeyListener I have on the tree is fired as well:

this.addKeyListener(new KeyAdapter() {
  public void keyReleased(KeyEvent e) {
    if (e.getKeyChar() == KeyEvent.VK_ENTER) {
      view.openPropertyWindow();
    }
  }
});

Where "this" is the JTree.

I've tried everything I can to prevent that listener from firing if
the tree is being edited.  Nothing seems to work.  Any suggestions?

0
Reply jason.cavett (211) 3/5/2007 8:54:01 PM


0 Replies
220 Views

(page loaded in 0.021 seconds)

Similiar Articles:




7/25/2012 10:15:34 PM


Reply: