views:

19

answers:

1

For multiple selection in a Jtree,I am using multiple selection mode in it.It works.But I want to know when i am making multiple selection exactly in this tree to do this i wrote a very simple keycontroller class that implements KeyListener, but i wanna check whether ctrl is pressed or not to do so i am using this code but it seems to be not working :

kc.getKeyCode() == KeyEvent.CTRL_DOWN_MASK ; what is the keyCode for ctrl ? Or am i doing something wrong ?

A: 

As CTRL is a key mask, there is no character for the CTRL key alone.

However, according to KeyEvent documentation, there is always a vaild key code that is sent when either a key is pressed or released. in that case, it should be KeyEvent.CHAR_UNDEFINED and getModifiersEx() should return true for the CTRL key. Notice that, for it to work, you have to register a KeyListener (specially handle for both keyPressed() and keyReleased()).

Riduidel
Is there a way to understand that i am making multiple selection in a spesific slection.I mean i dont want to lose the previous selected item,when i am making multiple selection.
gustavo