-
Notifications
You must be signed in to change notification settings - Fork 0
/
PropertyAttributePanel.java
51 lines (44 loc) · 1.43 KB
/
PropertyAttributePanel.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
import javax.swing.*;
import java.awt.*;
import javax.imageio.ImageIO;
import java.io.InputStream;
import java.io.IOException;
/** Class to implement the property attribute pop up of the GUI, containing
* description of the property and button choices
* @author Joseph
*
* Credits: http://monopoly.wikia.com/wiki/Property
*/
public class PropertyAttributePanel extends JPanel {
/** The property attritube image */
private Image _property;
/** The Monopoly GUI Board Panel */
private BoardPanel _boardPanel;
public PropertyAttributePanel(String property, BoardPanel boardPanel) {
super();
_boardPanel = boardPanel;
InputStream in = getClass().getResourceAsStream(
"resources/properties_images/" + property + ".jpg");
try {
_property = ImageIO.read(in);
} catch (IOException e) {
System.out.println("error loading board image.");
System.exit(1);
}
this.setOpaque(false);
this.setLayout(null);
}
@Override
protected void paintComponent(Graphics g) {
drawComponent((Graphics2D) g);
}
private void drawComponent(Graphics2D g) {
// Draws the Property Attribute Image
g.drawImage(_property, 0, 0, 350, 245, null);
JButton exit = new JButton("Exit");
exit.setLocation(138, 250);
exit.setSize(75, 50);
exit.addActionListener(_boardPanel);
add(exit);
}
}