import java.awt.*; import javax.swing.*; public class DrawArcs extends JFrame { public DrawArcs() { super ("Menggambar Arc"); setSize (600,400); setVisible (true); } public void paint (Graphics g) { super.paint (g); g.setColor (Color.RED); g.fillArc (130,30,340,340,0,90); //(x,y,width,height,mulai,sudut) g.setColor (Color.BLACK); g.drawString("Kecamatan",330,140); g.drawString("A",350,160); g.setColor (Color.GREEN); g.fillArc (130,30,340,340,90,135); //(x,y,width,height,mulai,sudut) g.setColor (Color.BLACK); g.drawString("Kecamatan",190,180); g.drawString("B",210,200); g.setColor (Color.YELLOW); g.fillArc (130,30,340,340,225,45); //(x,y,width,height,mulai,sudut) g.setColor (Color.BLACK); g.drawString("Kecamatan",230,300); g.drawString("C",250,320); g.setColor (Color.BLUE); g.fillArc (130,30,340,340,270,90); //(x,y,width,height,mulai,sudut) g.setColor (Color.BLACK); g.drawString("Kecamatan",330,270); g.drawString("D",350,290); //g.drawRect (130,30, } public static void main (String args[]) { DrawArcs test = new DrawArcs(); test.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); } }
Saya hanya menshare source code nya, jadi untuk fungsi masing - masing variable silahkan di oprek sendiri :D
Selamat Mencoba!!
Tidak ada komentar:
Posting Komentar