java 2d graphics eraser

44 views Asked by At

is there a easy way to Locate the Drawed Line in my PaintComponent Array to delete this Line. Like a Eraser?

Here my PaintComponent Class

protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.setStroke(new BasicStroke(5));
    g2d.setColor(Color.RED);
    for (Point[] p : glaslist) {
        g2d.setColor(Color.yellow);
        g2d.drawLine(p[0].x, p[0].y, p[1].x, p[1].y);
    }
    for (Point[] p : kupferlist) {
        g2d.setColor(Color.ORANGE);
        g2d.drawLine(p[0].x, p[0].y, p[1].x, p[1].y);

    }
    if (startPoint != null && endPoint != null) {
        
            g2d.setColor(Color.RED);
            g2d.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
        
    }

    g2d.dispose();

}
0

There are 0 answers