Everytime I try to call the repaint() method it says a non static method cannot be reference from a static method. Btw, it\'s in the same class as the paintComponent method. I t
The main method is static. Your p object is not: it is an instance field of the P class. Try this:
public static void main(String[] args) throw InterruptedException {
EventQueue.invokeLater( new Runnable() {
public void run() {
P p = new P();
p.repaint();
}
} );
}
You should always access Swing components from the event dispatch thread, which is why I put it all in a EventQueue invokeLater.