Answer the question
In order to leave comments, you need to log in
Why does everything drawn on the frame disappear when the window is minimized?
I made a mini-drawer (on the first two mouse clicks a line is created, on the rest it turns into a polyline, etc. + when you click on one of the existing points, the polyline "closes"), but a problem popped up: draw yourself, draw, minimize the window, unfold - and it's all erased. Tell me how to fix it?
before folding:
after:
If necessary, I will throw the entire code of the program
Answer the question
In order to leave comments, you need to log in
Because the contents of the window are redrawn when minimized, obscured by another window, resized, etc. You need to store your creativity in memory and redraw during the window redraw event.
public class MyPanel extends JPanel {
public void paint(Graphics g) {
// do your painting here
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question