I’ve got a following problem. I want to draw lines over BufferedImage, but they don’t show up. If i don’t load the image, they will show. What is the problem? Here is my code:
@Override
public void paintComponent(Graphics g) {
prepareImage();
g.drawImage(buffer, 0, 0, null);
g.dispose();
}
private void prepareImage() {
Graphics g = buffer.createGraphics();
g.drawImage(mapImage, 0, 0, null);
g.setColor(Color.RED);
for (Line line : lines)
g.drawLine(line.x1, line.y1, line.x2, line.y2);
lines.clear();
g.dispose();
}
Thanks for help.
I see two issues in your code: