how to update?
I have a canvas frame where when user clicks 1st time I store that point in an array...when user clicks 2nd time I store the 2nd point again so on ...and I call repaint method in the 2nd click mouse clicked().
Now in paint I display the lines...
But till the time I press the mouse for a third click the first line(comprising of first two mouse clicks) doesnot print.
Any 1 please reply
addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
if(rtclick==false)
{
/*if(mp.gate_place==true)
{
gate_place=false;
alen++;
and[alen].x=x;
and[alen].y=y;
repaint();
System.out.println("AND");
repaint();
return;
}*/
if(clicked==false)//1st click
{
linelength++;
line[linelength].sx=e.getX();
line[linelength].sy=e.getY();
clicked=true;//1 click has happened
repaint();
}
else
{//2nd click thus target
line[linelength].tx=e.getX();
line[linelength].ty=e.getY();
myframe m = (myframe)e.getSource();
m.repaint();
e.consume();
//repaint();
clicked=false;//2 click has happened
}
System.out.println("in center clkd"+e.getX()+" "+e.getY());
}
}//end of mouseClicked()
});
public void paint(Graphics g)
{
int i,j;
super.paint(g);
for(j=0;j<linelength;j++)
{
g.drawLine(line[j].sx,line[j].sy,line[j].tx,line[j].ty);
}
}
}//end of class myframe>

