PieChart - /* / PieChart.java / / Draws a pie chart showing...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//***************************************************************** // PieChart.java // // Draws a pie chart showing percentage of household income // spent on various expenses. //***************************************************************** import javax.swing.JApplet; import java.awt.*; public class PieChart extends JApplet { public void paint (Graphics page) { final int DEGREES_IN_CIRCLE = 360; final int APPLET_WIDTH = 600; final int APPLET_HEIGHT = 400; int x, y; // corner point for the pie chart int diameter; // diameter of the pie chart int startAngle; // starting angle for a pie slice int arcAngle; // arc angle for a pie slice diameter = 200; x = (APPLET_WIDTH - diameter)/2; y = (APPLET_HEIGHT - diameter)/2; setBackground (Color.white); // Draw rent and utilities slice page.setColor (Color.blue); startAngle = 0; arcAngle = (int) (0.35 * DEGREES_IN_CIRCLE); page.fillArc (x, y, diameter, diameter, startAngle, arcAngle); page.drawString ("Rent and Utilities (35%)", x + diameter - 15, y + 30);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Page1 / 2

PieChart - /* / PieChart.java / / Draws a pie chart showing...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online