• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Multi-Modes Button

 
Enock Banacson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I make a button to do different events,
Say my Button text is 3jk and I want it display 3 on my text area when clicked once, display j on doble click and k clicking it three times.
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I don't believe button can detect how many click, simply because you can't double-click a button.
You can however do a loop base, the first click, display one value, then next value, then next value.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use addMouseListener() to get a MouseEvent for each click - this has a getClickCount() method which can be useful for detecting double clicks. As I recall you may need to look at the elapsed time between two clicks to decide if they're really "close enough" to count as a double click. There may well be a better way, but I don't know it.
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adrian Yan:
Actually, I don't believe button can detect how many click, simply because you can't double-click a button.

Ohh.. good point !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic