-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgressButton.java
More file actions
65 lines (57 loc) · 1.61 KB
/
ProgressButton.java
File metadata and controls
65 lines (57 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
/**
* Shows the progress of the song on the progress bar. Controlled by a
* ProgressBar object.
*
* @author Michael Nipper
*
*/
public class ProgressButton extends Button implements ActionListener {
private float pixelRounder;
/**
* @param x
* x-coordinate for the button
* @param y
* y-coordinate for the button
* @param width
* width of the button
* @param height
* height of the button
* @param upImage
* image to show when the button is not being pressed
* @param downImage
* image to show when the button is being pressed
*/
public ProgressButton(int x, int y, int width, int height,
ImageIcon upImage, ImageIcon downImage) {
super(x, y, upImage, downImage);
addActionListener(this);
this.setWidth(width);
this.setHeight(height);
pixelRounder = x;
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
/**
* Increment the progress button to progress through the song.
*
* @param pixels
* The number of pixels to progress.
*/
public void moveButton(double pixels) {
pixelRounder += pixels;
this.setxPosition(Math.round(pixelRounder));
this.setLocation(this.getxPosition(), this.getyPosition());
}
/**
* Set the ProgressButton object back to its initial position at the
* beginning of the ProgressBar.
*/
public void refreshPixelRounder() {
pixelRounder = 30;
}
}