Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

paintComponent not working

807598Jan 29 2006 — edited Jan 29 2006
I have overridden the paintComponent method in a class which extends JPanel but the JPanel will not display anything I have created in the paintComponent method. Here is the code im using -
 public void paintComponent(Graphics g) 
    {
        super.paintComponent(g);
        g.setColor(Color.black);
        g.drawRect(100, 100, 50, 50);
        
    }
Has anyone got any idea why the rectangle is not displaying on my JPanel, do I have to make a call to the paintComponent method?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2006
Added on Jan 29 2006
6 comments
346 views