Exercise14_9 - int radius = (int)(Math.min(getWidth(),...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Danielle Green */ import java.awt.*; import javax.swing.*; public class Exercise14_9 extends JFrame { public Exercise14_9() { setTitle("Drawing a Fan"); Container circle = getContentPane(); circle.setLayout(new GridLayout (2,2,5,5)); circle.add(new FanPanel()); circle.add(new FanPanel()); circle.add(new FanPanel()); circle.add(new FanPanel()); } class FanPanel extends JPanel { protected void paintComponent(Graphics g) { super.paintComponents(g); int centerX = getWidth() / 2; int centerY = getHeight() / 2;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int radius = (int)(Math.min(getWidth(), getHeight()) * 0.4); int x = centerX - radius; int y = centerY - radius; g.fillArc(x,y,2 * radius, 2 * radius, 0,30); g.fillArc(x,y,2 * radius, 2 * radius, 90,30); g.fillArc(x,y,2 * radius, 2 * radius, 180,30); g.fillArc(x,y,2 * radius, 2 * radius, 270,30); } } public static void main(String args) { JFrame frame = new Exercise14_9(); frame.setSize(300,300); frame.setTitle("Exercise14_9"); frame.setDefaultCloseOperation(3); frame.setLocationRelativeTo(null); frame.setVisible(true); } }...
View Full Document

Ask a homework question - tutors are online