1 | package gamegui;
|
---|
2 |
|
---|
3 | import java.awt.*;
|
---|
4 | import java.awt.event.MouseEvent;
|
---|
5 | import java.util.*;
|
---|
6 |
|
---|
7 | public class Window extends Member
|
---|
8 | {
|
---|
9 | ArrayList<Member> members;
|
---|
10 | boolean fullscreen;
|
---|
11 |
|
---|
12 | public Window(String newName, int newX, int newY, int newWidth, int newHeight) {
|
---|
13 | super(newName, newX, newY, newWidth, newHeight);
|
---|
14 |
|
---|
15 | members = new ArrayList<Member>();
|
---|
16 | }
|
---|
17 |
|
---|
18 | public Window(String newName, int newX, int newY, int newWidth, int newHeight, boolean full) {
|
---|
19 | super(newName, newX, newY, newWidth, newHeight);
|
---|
20 |
|
---|
21 | members = new ArrayList<Member>();
|
---|
22 | fullscreen = full;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public void draw(Graphics g) {
|
---|
26 | g.setColor(Color.black);
|
---|
27 | g.fillRect(getX(), getY(), getWidth(), getHeight());
|
---|
28 |
|
---|
29 | if(!fullscreen)
|
---|
30 | {
|
---|
31 | g.setColor(Color.red);
|
---|
32 | g.drawRect(getX(), getY(), getWidth(), getHeight());
|
---|
33 | }
|
---|
34 |
|
---|
35 | for(int x=0; x < members.size(); x++)
|
---|
36 | members.get(x).draw(g);
|
---|
37 | }
|
---|
38 |
|
---|
39 | public boolean handleEvent(MouseEvent e) {
|
---|
40 | boolean val = false;
|
---|
41 |
|
---|
42 | for(int x=0; x < members.size(); x++)
|
---|
43 | val = val || members.get(x).handleEvent(e);
|
---|
44 |
|
---|
45 | return val;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public void clear() {
|
---|
49 | for(int x=0; x < members.size(); x++)
|
---|
50 | members.get(x).clear();
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void add(Member aMember) {
|
---|
54 | aMember.offset(getX(), getY());
|
---|
55 |
|
---|
56 | members.add(aMember);
|
---|
57 | }
|
---|
58 |
|
---|
59 | public void offset(int xOffset, int yOffset) {
|
---|
60 | super.offset(xOffset, yOffset);
|
---|
61 |
|
---|
62 | for(int x=0; x < members.size(); x++)
|
---|
63 | members.get(x).offset(xOffset, yOffset);
|
---|
64 | }
|
---|
65 |
|
---|
66 | public Member getMember(String aName) {
|
---|
67 | for(int x=0; x < members.size(); x++)
|
---|
68 | if(members.get(x).getName().equals(aName))
|
---|
69 | return (Member)members.get(x);
|
---|
70 |
|
---|
71 | return null;
|
---|
72 | }
|
---|
73 | }
|
---|