aspose file tools*
The moose likes Java in General and the fly likes Java Multi-Modes Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Multi-Modes Button" Watch "Java Multi-Modes Button" New topic
Author

Java Multi-Modes Button

Enock Banacson
Greenhorn

Joined: Sep 30, 2003
Posts: 8
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

Joined: Oct 02, 2000
Posts: 688
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

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
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 !


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Multi-Modes Button