Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Why don't my graphics appear on the panel?

+15 votes

I'm calling g.fillOval(...) correctly, but I don't see anything appear!

asked Jan 14, 2016 in (Winter 15-16) by Forrest Stonedahl (3,308 points)

2 Answers

+4 votes

One explanation is that you have a black background for your panel, and you never set your paint color to be anything.  The default draw/fill color is black, until you set it!

answered Jan 14, 2016 by Forrest Stonedahl (3,308 points)
+4 votes

Another explanation is that you might have coordinates that are outside the X/Y range of your window, so you *are* drawing a dot, but it's off the screen.  Write before the .fillOval(x,y,width,height) command, you can put in

System.out.println("x=" + x + " and y=" +y);

to see what coordinates you are drawing at...

answered Jan 14, 2016 by Forrest Stonedahl (3,308 points)
...