forked from SeanWalsh95/Ticket-To-Ride
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRulesPanel.java
76 lines (72 loc) · 2.46 KB
/
RulesPanel.java
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
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
/**
* A extension of the JPanel class to diplay the rules of
* ticket to ride to a player
*
* @author Sean Walsh
* @version 1.0
*/
public class RulesPanel extends JPanel
{
// backround image to paint behind everything
Image background;
/**
* Constructor for objects of class RulesPanel
*/
public RulesPanel()
{
this.setLayout(null);
JPanel self = this;
//makes the mouse cursor
Toolkit toolkit = Toolkit.getDefaultToolkit();
Cursor a = toolkit.createCustomCursor(ImgLib.mouseCursor,
new Point(this.getX(),this.getY()), "img");
setCursor(a);
background = ImgLib.rulesScreen1;
GButton next = new GButton(new int[]{962, 13, 80, 30},
ImgLib.nextButtonUnselected, ImgLib.nextButtonHighlighted,
ImgLib.nextButtonPressed);
next.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SoundLib.turnPage.play();
background = ImgLib.rulesScreen2;
repaint();
}
});
this.add(next);
GButton previous = new GButton(new int[]{219, 13, 80, 30},
ImgLib.previousButtonUnselected,
ImgLib.previousButtonHighlighted,
ImgLib.previousButtonPressed);
previous.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SoundLib.turnPage.play();
background = ImgLib.rulesScreen1;
repaint();
}
});
this.add(previous);
GButton back = new GButton(new int[]{5, 846, 98, 48},
ImgLib.backButtonUnselected, ImgLib.backButtonHighlighted,
ImgLib.backButtonPressed);
back.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SoundLib.button.play();
((JDialog)
SwingUtilities.windowForComponent(self)).dispose();
}
});
this.add(back);
}
/**
* Paint component method for this JPanel component
*
* @param g the Graphics object for this Class
*/
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(background, 0, 0, this);
}
}