File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes mouse clicks using timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "mouse clicks using timer" Watch "mouse clicks using timer" New topic
Author

mouse clicks using timer

akila kann
Greenhorn

Joined: May 31, 2001
Posts: 2
Dear sir,
I am writing a program to detect mouse clicks over a mobile phone image.I am printing the alphabets on to a textarea.I want to write 2 on first click,a on second click,and b on third click and c on 4th click,the same has to be repeated in a loop for sometime(for this the timer should be running).I want the cursor on the textarea to be blinking for sometime and if the timer is elapsed it should get the next alhabet or letter?
Could u help me in doing this with javax.swing.timer
I need the sample code as early as possible
Thanks,
Akila
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Akila,
Call me confused!
Why do you need a timer if you are trying to keep track of mouse clicks? Why don't you start with a on the first click? The number 2 (first click) is not a alphabet character ...
Some more information is required to help you out ... maybe show some code that you have tried and doesn't work ...
Regards,
Manfred.
karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
hi,
for the cursor to move, just start a javax.swing.Timer
Timer t = new Timer(time, anActionListener);
t.start();
where <code>time</code> is the delay in msecs until 'public void actionPerformed(ActionEvent ae) of <code>anActionListener</code> gets invoked. the ActionListener might be the class controling the cursor. it implements the ActionListener interface (java.awt.event). now everytime you click on the image you have to restart the timer: t.restart(). this clears it and starts again with the initial delay. (this ensures the cursors moves <code>time</code> msecs after LAST click).
karl
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mouse clicks using timer