Class Window

java.lang.Object
  extended by gui.Darstellung
      extended by Window

public class Window
extends gui.Darstellung


Constructor Summary
Window()
          This constructor method creates a window with a simple 4x4 gameboard area in it.
Window(int numberOfHorizontalSquares, int numberOfVerticalSquares)
          This constructor method creates a window with a simple gameboard area in it.
Window(int numberOfHorizontalSquares, int numberOfVerticalSquares, int squareWidth, int squareHeight)
          This constructor method creates a window with a simple gameboard area in it.
 
Method Summary
 void addButtons(java.lang.String[] buttonList)
          Adds a number of buttons on the right side of the window.
 void drawImage(int id, java.lang.String imageName)
          The gameboard consists of numbered squares.
 void setBackgroundColor(int id, java.lang.String color)
          Setzt bei einer Spielfeld-Zelle die Hintergrundfarbe
 void setReceiver(gui.Knopfempfaenger receiver)
          Wer soll die Nachricht kriegen, wenn ein Knopf oder eine Spielfeldzelle gedrueckt werden?
 void show(java.lang.String messageText)
          Weist das Ausgabefeld an, eine Nachricht anzuzeigen.
 
Methods inherited from class gui.Darstellung
ausgabeHinzufuegen, bildSetzen, hatAusgabeFlaeche, hintergrundfarbeSetzen, keyboardempfaengerSetzen, knoepfeHinzufuegen, knoepfeHinzufuegenLinks, knoepfeHinzufuegenRechts, knopfempfaengerSetzen, knopfnachrichtSetzen, knopfnachrichtSetzen, knopftextSetzen, knopftextSetzen, spielflaecheHinzufuegen, textAnzeigen, textAnzeigen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Window

public Window()
This constructor method creates a window with a simple 4x4 gameboard area in it. Each square has a size of 100x100 pixels.


Window

public Window(int numberOfHorizontalSquares,
              int numberOfVerticalSquares)
This constructor method creates a window with a simple gameboard area in it. Each square has a size of 100x100 pixels.

Parameters:
numberOfHorizontalSquares - The number of horizontal squares for the gameboard. Chess has 8, for example, and Connect Four has 7.
numberOfVerticalSquares - The number of vertical squares for the gameboard. Chess has 8, for example, and Connect Four has 5.

Window

public Window(int numberOfHorizontalSquares,
              int numberOfVerticalSquares,
              int squareWidth,
              int squareHeight)
This constructor method creates a window with a simple gameboard area in it.

Parameters:
numberOfHorizontalSquares - The number of horizontal squares for the gameboard. Chess has 8, for example, and Connect Four has 7.
numberOfVerticalSquares - The number of vertical squares for the gameboard. Chess has 8, for example, and Connect Four has 5.
squareWidth - How wide each square is in pixels, for example 100
squareHeight - How high each square is in pixels, for example 100
Method Detail

addButtons

public void addButtons(java.lang.String[] buttonList)
Adds a number of buttons on the right side of the window. Each button, when you press it, sends a message to the receiver (if there is one). The message consists of the label for the button, i.e. what is written on the button.

Parameters:
buttonList - This is an array of Strings, for example: new String [] { "one," "two", "three"}. A button will be created for each String.

drawImage

public void drawImage(int id,
                      java.lang.String imageName)
The gameboard consists of numbered squares. This methods draws an image on any one of those squares.

Parameters:
id - The number of the square, the first one (staring top left) has the number 0.
imageName - The name of the file with the image. The file must be in the BlueJ folder or a subfolger, for example "material/figure.png"

setBackgroundColor

public void setBackgroundColor(int id,
                               java.lang.String color)
Setzt bei einer Spielfeld-Zelle die Hintergrundfarbe

Parameters:
id - Die Nummer der Zelle, angefangen links oben bei 0
color - Die Farbe. Zulaessige Farben sind im Moment: "blau", "weiss", "rot", "gelb", "gruen", "grau", "magenta" . Weitere Fragen auf Anfrage.

setReceiver

public void setReceiver(gui.Knopfempfaenger receiver)
Wer soll die Nachricht kriegen, wenn ein Knopf oder eine Spielfeldzelle gedrueckt werden? Dieser Empfaenger wird mit dieser Methode gesetzt.

Parameters:
receiver - Der Empfaenger der Knopfnachricht. Er muss direkt oder indirekt das Interface "Knopfempfaenger" erfuellen, damit ist gewaehrleistet, dass er die zwei noetigen Methoden hat, auf die diese Klasse hier zugreift.

show

public void show(java.lang.String messageText)
Weist das Ausgabefeld an, eine Nachricht anzuzeigen. Wenn noch kein Ausgabefeld existiert, wird eines angelegt.

Parameters:
messageText - Der anzuzeigende Text, z.B. "Am Zug: Spieler 1"