The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


swing graphix

Posted by Syrion on October 02, 2001 at 8:03 AM

Do you call super.paintComponent(g) at first ? then you can call g.drawWhatYouWant(...).
You must extend a class that have a paintComponent(Graphics g) method. Typically, you have JPanel
public class MyScreen extends JPanel{
//your own constructors, attributes, function...
public void paintComponent(Graphics g){//---> must work
> I'm creating an applet of a ball bouncing across a panel. Try as I might, I cannot get the Graphics class to paint the ball on the screen. I'm logging the coordinates where the ball should be, and can virtually "see" the ball bounce across the panel. However, the graphical representation of the ball is not there. I have all my paint commands in paintComponent(). I've even tried calling repaint() to no avail. I am not calling any of the old AWT methods like paint() or update(). Might this have something to do with which Graphics object gets painted on? Please help me figure this out - it's driving me nuts!


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us