-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathShuffleButton.java
More file actions
78 lines (72 loc) · 2.16 KB
/
ShuffleButton.java
File metadata and controls
78 lines (72 loc) · 2.16 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
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
/**
* The shuffle button for the GUI.
*
* @author Michael Nipper
*
*/
public class ShuffleButton extends Button implements ActionListener {
private Window window;
private ProgressBar progressBar;
/**
* @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
* @param w
* the Window object to attach the ProgressButton.
*/
public ShuffleButton(int x, int y, int width, int height,
ImageIcon upImage, ImageIcon downImage, Window w) {
super(x, y, upImage, downImage);
addActionListener(this);
this.setWidth(width);
this.setHeight(height);
window = w;
}
@Override
public void actionPerformed(ActionEvent e) {
if (getMediaController().isPlaylistSet()) {
if (getMediaController().shuffleStatus()) {
getMediaController().unshuffle();
ImageIcon pause = new ImageIcon("images/shuffleButton.png");
ImageIcon pausePressed = new ImageIcon(
"images/shuffleButtonPressed.png");
this.setGraphicUp(pause);
this.setGraphicDown(pausePressed);
} else {
getMediaController().shuffle();
ImageIcon pause = new ImageIcon(
"images/shuffleButtonActive.png");
ImageIcon pausePressed = new ImageIcon(
"images/shuffleButtonActivePressed.png");
this.setGraphicUp(pause);
this.setGraphicDown(pausePressed);
window.refreshLabels();
progressBar.refresh(getMediaController());
progressBar.start();
}
}
this.setIcon(this.getGraphicUp());
this.setPressedIcon(this.getGraphicDown());
}
/**
* Set a ProgressBar object for the ShuffleButton to control.
*
* @param p
* The ProgressBar object to control.
*/
public void setProgressBar(ProgressBar p) {
progressBar = p;
}
}