• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

why do I get a whole red pie???

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use some colors to make my circle with the following code.

public void paint(Graphics g){
Graphics2D g2 = (Graphics2D) g;
g2.fill(new Arc2D.Double(10, 10, 200, 200, 0,100, Arc2D.PIE));
g2.setPaint(Color.blue );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 100,120, Arc2D.PIE));
g2.setPaint(Color.darkGray );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 120,135, Arc2D.PIE));
g2.setPaint(Color.green );
g2.fill(new Arc2D.Double(10, 10, 200, 200,135,270, Arc2D.PIE));
g2.setPaint(Color.cyan );
g2.fill(new Arc2D.Double(10, 10, 200, 200,270,290, Arc2D.PIE));
g2.setPaint(Color.lightGray );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 290,300, Arc2D.PIE));
g2.setPaint(Color.red );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 300,360, Arc2D.PIE));
}
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Caven,
You are putting the wrong value into the sixth parameter of the Arc2D double method call. THe sizth parameter is the amount of angle to cover and not the ending angle. You case:

All sixth values add up to full circle or 360 degrees.
Regards,
Manfred.
 
Caven Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I saw your answer , I come to realize my stupidity. Thank you sooooooooooooooooooooo much!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!