// Scott DeRuiter // 3/12/2013 - Greenstein: Change from applet to JFrame // March 12, 2013 // Pinwheel.java // Creates a multicolored circle. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Pinwheel { JFrame frame; DisplayWheel panel; public static void main(String[] args) { Pinwheel pw = new Pinwheel(); pw.Run(); } public void Run() { frame = new JFrame("Pinwheel"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create JPanel and add to frame panel = new DisplayWheel(); frame.getContentPane().add(panel, BorderLayout.CENTER); // add panel to frame frame.setSize(500, 500); // explicitly set size in pixels frame.setVisible(true); // set to false to make invisible } } class DisplayWheel extends JPanel { DisplayWheel() { setBackground(Color.black); } public void paintComponent(Graphics g) { super.paintComponent(g); for ( int i = 1; i <= 36; i++ ) { int value = i % 6 + 1; switch ( value ) { case 1: g.setColor ( Color.blue ); break; case 2: g.setColor ( Color.magenta ); break; case 3: g.setColor ( Color.green ); break; case 4: g.setColor ( Color.gray ); break; case 5: g.setColor ( Color.yellow ); break; case 6: g.setColor ( Color.red ); break; } g.fillArc ( 10, 10, 300, 300, i * 10, 10 ); } } }