package gamegui; import java.awt.event.MouseEvent; import java.awt.Color; import java.awt.Graphics; import utils.DynamicImage; import java.util.ArrayList; public class Window extends Member { ArrayList members; public DynamicImage background; boolean fullscreen; public Window(final String newName, final int newX, final int newY, final int newWidth, final int newHeight) { super(newName, newX, newY, newWidth, newHeight); this.members = new ArrayList(); this.background = null; } public Window(final String newName, final int newX, final int newY, final int newWidth, final int newHeight, final boolean full) { super(newName, newX, newY, newWidth, newHeight); this.members = new ArrayList(); this.background = null; this.fullscreen = full; } @Override public void draw(final Graphics g) { g.setColor(Color.black); g.fillRect(this.getX(), this.getY(), this.getWidth(), this.getHeight()); if (this.background != null) { this.background.draw(g, 0, 0); } if (!this.fullscreen) { g.setColor(Color.red); g.drawRect(this.getX(), this.getY(), this.getWidth(), this.getHeight()); } for (int x = 0; x < this.members.size(); ++x) { this.members.get(x).draw(g); } } @Override public boolean handleEvent(final MouseEvent e) { boolean val = false; for (int x = 0; x < this.members.size(); ++x) { val = (val || this.members.get(x).handleEvent(e)); } return val; } @Override public void clear() { for (int x = 0; x < this.members.size(); ++x) { this.members.get(x).clear(); } } public void add(final Member aMember) { aMember.offset(this.getX(), this.getY()); this.members.add(aMember); } public void offset(final int xOffset, final int yOffset) { super.offset(xOffset, yOffset); for (int x = 0; x < this.members.size(); ++x) { this.members.get(x).offset(xOffset, yOffset); } } public Member getMember(final String aName) { for (int x = 0; x < this.members.size(); ++x) { if (this.members.get(x).getName().equals(aName)) { return this.members.get(x); } } return null; } }