I am trying to display a filled oval on the screen using a subclass of JPanel when I try to add an object of this subclass to a JFrame with FlowLayout the oval is not displayed correctly I don't know what the problem is. Could you help me please?
here's my code
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLACK);
g.fillOval(0, 0, 50, 50);
}
in main
JFrame frame = new JFrame("Ball");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.setLayout(new FlowLayout());
BallPanel ball = new BallPane();
frame.add(ball);