I have a JTree with a TreeSelectionListener to load a form when the
node selection changes. I want to be able to perform a slightly
different action when the selection changes while the CTRL key is
pressed, but the TreeSelectionEvent does not provide access to the
modifier key state.
I am only necessarily interested in the modifier state if the selection
changes by a mouse click, so I could use a MouseListener for this case
if I could figure out a way to keep the TreeSelectionListener from also
loading the form for this case (I have to keep the
TreeSelectionListener method of switching forms for non-mouse-triggered
changes), since both listeners will fire for a mouse selection change.
So, in short, the ideal solution I seek is a way to know if the CTRL
key is pressed from within the TreeSelectionListener, and if that is
too impractical, then a way to keep the TreeSelectionListener from
performing a form load if the MouseListener is going to handle it.
elrod@therod.org - 09 Jan 2006 15:39 GMT
> I have a JTree with a TreeSelectionListener to load a form when the
> node selection changes. I want to be able to perform a slightly
[quoted text clipped - 12 lines]
> too impractical, then a way to keep the TreeSelectionListener from
> performing a form load if the MouseListener is going to handle it.
Or, perhaps a simpler question to answer; where does a new MouseEvent
originate? When it is generated, how is its 'modifiers' field
populated? I tried to delve into the java source, but did not find an
answer. I'm guessing (but hoping I am wrong) that the event is
generated by system code, and as such, there is no accessible function
for getting the modifiers.