FanPanel

FanPanel - } public void setDelay(int delayValue){

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

View Full Document Right Arrow Icon
// Assignment #: 12 // Name: your name // StudentID: your id // Lecture: your lecture // Description: it needs to be filled. / import javax.swing.*; i import java.awt.*; import java.awt.event.*; import javax.swing.event.*; i public class FanPanel extends JPanel { private Color color; private int width; private Timer timer; private int delay; private int step; private int centerX; private int centerY; private int diameter; private int currentAngle; //added all intergers p public FanPanel(Color color, int width) { this.color = color; this.width = width; delay = 20; step = 3; setBackground(Color.WHITE); currentAngle = 0; centerX = (width / 2); centerY = (width / 2); diameter = (width - 10) / 2; timer = new Timer(delay, new MoveListener()); timer.start(); t } public void resume() { timer.start(); } public void suspend() { timer.stop(); t } public void reverse() { step = step*(-1); timer.start(); //in case its not moving to start the moving
Background image of page 1

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

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

Unformatted text preview: } public void setDelay(int delayValue){ timer.setDelay(delayValue); t } public void paintComponent(Graphics page) { super.paintComponent(page); page.setColor(color); page.fillArc(centerX-diameter/2, centerY-diameter/2, diameter, diameter, currentAngle, 90); //orig had it (1/2) but that messed it up because the remainder is 0. / page.setColor(color); page.fillArc(centerX-diameter/2, centerY-diameter/2, diameter, diameter, currentAngle-180, 90); //were learning about angles in calculus right now. page.setColor(color); page.drawOval(centerX-diameter/2, centerY-diameter/2, diameter, diameter); } private class MoveListener implements ActionListener{ public void actionPerformed(ActionEvent event){ currentAngle= currentAngle + step; // current angle PLus step repaint(); //if this isnt here it wont spin. r } } }...
View Full Document

Page1 / 2

FanPanel - } public void setDelay(int delayValue){

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