Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterating the EventQueue

 
Alex Ku
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem I am having is about JTree.
I have a MouseListener on the tree.
When user single-clicks on a node, the program will perform some tasks.
When user double-clicks, the program will just expand/collapse the node, but not perform the tasks.
The problem is when double-click, the MouseClicked will be called twice.
Like this:
MouseClicked(...) //with e.getClickCount = 1
MouseClicked(...) //with e.getClickCount = 2
The task will be performed twice and the node will be expanded if it is double-click. Is there a way to find out if it is a double-click with e.getClickCount() is still 1?
I know the peekEvent only return the first event.
Is there a way to get all the event pending in the event queue? So, if there is a MouseClick event with clickcount > 1, then the program will just skip the task?
Like this:

I hope you know what I want.
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic