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
Joined: Jan 09, 2001
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.
Joined: May 25, 2001
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