How can I keep the lines that have been drawn previously after calling repaint()
this is my paintComponent
public void paintComponent( Graphics g )
{
graphics2D = (Graphics2D)g;
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics2D.setPaint(Color.white);
graphics2D.fillRect(0, 0, getSize().width, getSize().height);
graphics2D.setColor(Color.black);
}
I've another method
public void show_line(line a)
{
graphics2D=(Graphics2D)this.getGraphics();
for(int i=1;i<a.getLine_segs().size();i++)
{
Point p1=a.getLine_segs().get(i-1);
Point p2=a.getLine_segs().get(i);
System.out.println(p1);
graphics2D.drawLine(p1.x, p1.y, p2.x, p2.y);
}
}
When I'm calling show_line lines are drawn..
But after calling repaint() from other methods then the drawn lines are gone. So how to keep them?