Repaint() don't call PaintComponent()

Hi , post simple code , i have put in PaintComponent() a System.out.println() to see if enter in the code when i call repaint() and the answer is no , so repaint don’t call PaintComponent() why??:

import javax.net.ssl.KeyManager;
import javax.swing.JFrame;
import java.awt.GridLayout;

public class Frame extends JFrame{



    public Frame(){
       GamePanel g = new GamePanel();
       add(g);
       setTitle("Frame");
       setSize(200,200);
       setResizable(false);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setVisible(true);
    }

    public static void main(String[] args) {
        Frame F= new Frame();
    }
}
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class GamePanel  extends JPanel implements Runnable{

public static Thread thread;


public GamePanel(){
    setBackground(Color.WHITE);
    thread=new Thread(this);
    thread.start();
}

public void PaintComponent(Graphics g){
   System.out.println("into");
   g.setColor(new Color(100,100,100));
   g.fillRect(0,0,100,100);
}

public void run(){
   while(true){
   repaint();
   try{
   thread.sleep(1000);
   }catch(InterruptedException e){}
   }
}


}

The solution to your problem is very simple.

paintComponent(Graphics g) has to begin with a lowercase letter. Allways watch for case sensitivity. If you would’ve used the @Override annotation you would have recognized this :).

If you are using eclipse, then whenever you override a method from a superclass, a little green carat will appear on the left, next to the line numbers.

Oh man , yes ;D…
No i use Textpad nothing IDE …

Are you experienced in programming? If not, I would seriously recommend the use of an IDE at least for the first few months because it will help you correct these sort of mistakes easily!

Definitely use an IDE.

Well i would recommend you to use textpad, but only if you just started learning java. But well if you did just start you’re probably wrong developing games right ahead :).