import java.util.*; import java.awt.*; import java.applet.*; import java.text.*; import java.awt.event.*; public class Hiirejubin extends Applet implements MouseListener { SimpleDateFormat formatter; // Formaadib näidatavat aega int count = 0; // Et mitu korda või nii long timeStart = 0; // long tüüpi esimese kliki aeg long timeEnd = 0; // long tüüpi viimase kliki aeg Date date; // Aeg Date formaadis String aeg; // Aeg string formaadis final int mitu = 100; // Mitut klikkimist me üldse loeme public void init() { resize(300,300); addMouseListener(this); } public void paint(Graphics g) { g.setColor(Color.black); String cnt = new String(); cnt = Integer.toString(count); g.drawString(cnt, 125, 125); if (count>=mitu) { formatter = new SimpleDateFormat ("mm:ss:ms", Locale.getDefault()); aeg = formatter.format(date); g.setColor(Color.blue); g.drawString("Ok, Sa vajutasid "+ cnt + " korda", 65, 150); g.drawString("See võttis aega: "+ aeg, 95, 170 ); } } public void mousePressed(MouseEvent e){ Graphics g=getGraphics(); count++; if (count==1) { date = new Date(); timeStart = date.getTime(); } if (count==mitu) { date = new Date(); timeEnd = date.getTime(); date = new Date(timeEnd-timeStart); } repaint(); } public void mouseReleased(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseClicked(MouseEvent e){} }