I can not understand why, as a result of the execution of the code, the oval is not displayed, and when using the paint(Graphics g) method, the oval is displayed.
Painting class:
public class Painting extends JFrame { Pan p = new Pan(); public Painting(String s){ super(s); add(p); } public static void main(String[] args) { Painting p = new Painting("First"); p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p.setBounds(50, 50, 600, 600); p.setVisible(true); } } Pan class:
public class Pan extends JPanel{ @Override public void paintComponents(Graphics g){ super.paintComponents(g); Graphics2D g2 = (Graphics2D) g; g2.setPaint(BLACK); g2.fillOval(100, 100, 200, 200); } }