This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Iterating the EventQueue

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic