I'm drawing shapes inside this JPanel, which is also inside another main JPanel. At repaint() it only draws the shapes for one millisecond and then they disappear. They don't stay painted, why? my paintComponent method is something like this
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (int i = 0; i < reportElements.size(); i++) {
this.reportElements.get(i).display((Graphics2D) pageComponents.get(i).getGraphics());
}
}
When the parent is a JEditorPane with setEditable() enabled, it works and we can see the shapes but when it's a JPanel, after a millisecond all I see is empty panels.