private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Graphics2D leinwand = (Graphics2D) jPanel1.getGraphics();
//Ich möchte, dass die vorheriege Linie bei jedem klick des Buttons verschwindet
Random rand = new Random();
int x1, y1, x2, y2;
x1 = rand.nextInt(200);
y1 = rand.nextInt(200);
x2 = rand.nextInt(200);
y2 = rand.nextInt(200);
leinwand.drawLine(x1, y1, x2, y2);
}
Graphics2D leinwand = (Graphics2D) jPanel1.getGraphics();
//Ich möchte, dass die vorheriege Linie bei jedem klick des Buttons verschwindet
Random rand = new Random();
int x1, y1, x2, y2;
x1 = rand.nextInt(200);
y1 = rand.nextInt(200);
x2 = rand.nextInt(200);
y2 = rand.nextInt(200);
leinwand.drawLine(x1, y1, x2, y2);
}