i want to draw the pie menu in java which has 8 pies inside oval all of equal size.
The problem is when I draw one arc inside oval next arc overlap the previous arc and change its color, but I want 8 equal size filled arcs inside circle with different colors. Can any one tell me how can I achieve this? Here is my code.
public class mypanel extends JPanel {
int mx = 20;
int my = 20;
int ms = 120;
int mg = 120;
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.red);
g2.drawOval(mx, my, 100, 100);
g2.fillArc(mx, my, 100, 100, 0, 45);
g2.setColor(Color.blue);
g2.fillArc(mx, my, 100, 100, 0, 60);
g2.setColor(Color.white);
g2.fillArc(mx, my, 100, 100, 0, 20);
g2.setColor(Color.black);
g2.fillArc(mx, my, 100, 100, 0, 80);
g2.setColor(Color.blue);
g2.fillArc(mx, my, 100, 100, 0, 95);
}
}
This should do the trick: