Java Graphics displaying issue

If you use the circle with Graphics and nothing is displayed, and your code is the following :

Pannel class :

package JFrame;

import java.awt.Graphics;

import javax.swing.JPanel;

public class Panneau extends JPanel {

 public void PaintComponent (Graphics g)
 {
  int x1 = this.getWidth()/4;
     int y1 = this.getHeight()/4;                      
     g.fillOval(x1, y1, this.getWidth()/2, this.getHeight()/2);
 }

}

Window class :

package JFrame;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Fenetre extends JFrame 
{

 public Fenetre()
 {
     this.setTitle("Ma première fenêtre Java");
     this.setSize(400, 250);
     this.setLocationRelativeTo(null);               
     this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     this.setContentPane(new Panneau());
     this.setVisible(true);
 }
}

Main class :

package JFrame;

import javax.swing.JFrame;

public class Test {

 public static void main (String[] args){

  Fenetre fenetre = new Fenetre();
 }

}

The display method of a Component is paintComponent(Graphics) with a lowercase p in paint (because every method name should start with a lowercase character).

You can set a PaintComponent(Graphics) method with an uppercase P but it won’t be called to draw the Component, so this is normal if the circle is not displayed.

A good practice when you want to define a methode from a parent class is to add an @Override annotation. It will be easier to read the code, and if you make a mistake with the loading method signature, you will get an explicite error after the compilation.

public class Panneau extends JPanel {

    @Override
    public void paintComponent(Graphics g) {