Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Ellipse2D question  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm doing a problem where I make a smiley face. I did it with using an arc to make the eyes and thought it looked corny, so I've been trying to mess around with making an ellipse for each eye.
I've never used Ellipse2D and am not sure what I'm doing wrong below. From what I see online in examples my syntax is correct. Any tips? (It's line 20.)

 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The draw(...) method is a Graphics2D method, so you need to use a Graphics2D object, not a Graphics object. One way to do this is to create a new graphics object and then dispose of it when you are finished with it:



Other comments:

1) You should NOT be overriding the paint method of a JFrame. Custom painting is done by overriding the paintComponent(...) method of a JPanel (or JComponent). Then you add the panel to the frame. Read the section from the Swing tutorial on Custom Painting for more information.

2) Variable names should be capitalized for every new word in the variable name. So "smilegraphic" should be "smileGraphic".
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!