怎样实现点击鼠标奇次输出1,偶次输出2
我想点击鼠标左健奇数次输出一张图片,偶数次输出另一张,请问怎么实现??
我这样做错在哪里??
public void mousePressed(MouseEvent event){
int x,y;
int count=0;
y=(int)(event.getX()/72);
x=(int)(event.getY()/72);
if(count%2==0)
{
image[x][y]=tk.getImage("img/2.gif");
repaint();
count=1;
};
else
{
image[x][y]=tk.getImage("img/1.gif");
repaint();
count=0;
}
}