Package edu.willamette.cs1.spellingbee
Class SpellingBeeGraphics
- Object
-
- edu.willamette.cs1.spellingbee.SpellingBeeGraphics
-
public class SpellingBeeGraphics extends Object
This class provides the graphics library framework for the SpellingBee application. The project handout describes the public methods in more detail.
-
-
Constructor Summary
Constructors Constructor Description SpellingBeeGraphics()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addButton(String name, SpellingBeeEventListener listener)
Adds a button to the control strip.void
addField(String name, SpellingBeeEventListener listener)
Adds a text field to the control strip at the bottom of the window, where the text field is defaulted to hold ten characters.void
addField(String name, SpellingBeeEventListener listener, int nchars)
Adds a text field to the control strip at the bottom of the window, where the text field is large enough to hold nchars characters.void
addWord(String word)
Adds a word to the word list displayed on the window.void
addWord(String word, Color color)
Adds a word to the word list displayed on the window using the specified color.void
clearWordList()
Clears the word list and erases all entries from the window.String
getBeehiveLetters()
Returns the letters in the beehive, all in uppercase.String
getField(String name)
Returns the text contained in the specified field.void
setBeehiveLetters(String letters)
Sets the letters in the beehive on the window, placing the first letter in the center hex.void
setField(String name, String text)
Sets the text contained in the specified field.void
showMessage(String msg)
Displays a message in the message area at the bottom of the window.void
showMessage(String msg, Color color)
Displays a message in the message area at the bottom of the window.
-
-
-
Method Detail
-
setBeehiveLetters
public void setBeehiveLetters(String letters)
Sets the letters in the beehive on the window, placing the first letter in the center hex. The letters are converted to uppercase before displaying them.- Parameters:
letters
- The letters to put in the beehive
-
getBeehiveLetters
public String getBeehiveLetters()
Returns the letters in the beehive, all in uppercase.- Returns:
- The letters in the beehive
-
clearWordList
public void clearWordList()
Clears the word list and erases all entries from the window.
-
addWord
public void addWord(String word)
Adds a word to the word list displayed on the window.- Parameters:
word
- The word to be added
-
addWord
public void addWord(String word, Color color)
Adds a word to the word list displayed on the window using the specified color.- Parameters:
word
- The word to be addedcolor
- The color of the word
-
showMessage
public void showMessage(String msg)
Displays a message in the message area at the bottom of the window.- Parameters:
msg
- The string to display
-
showMessage
public void showMessage(String msg, Color color)
Displays a message in the message area at the bottom of the window. This version of the method allows the caller to set the text color.- Parameters:
msg
- The string to displaycolor
- The color of the text
-
addField
public void addField(String name, SpellingBeeEventListener listener, int nchars)
Adds a text field to the control strip at the bottom of the window, where the text field is large enough to hold nchars characters. When the user hits RETURN or ENTER in the text field, the implementation calls the specified listener function, passing in the value of the text field.- Parameters:
name
- The name of the text field, which appears as a labellistener
- A callback function that listens for a RETURNnchars
- The number of characters in the field
-
addField
public void addField(String name, SpellingBeeEventListener listener)
Adds a text field to the control strip at the bottom of the window, where the text field is defaulted to hold ten characters.- Parameters:
name
- The name of the text field, which appears as a labellistener
- A callback function that listens for a RETURN
-
getField
public String getField(String name)
Returns the text contained in the specified field.- Parameters:
name
- The name of the field- Returns:
- The contents of the field
-
setField
public void setField(String name, String text)
Sets the text contained in the specified field.- Parameters:
name
- The name of the fieldtext
- The new contents of the field
-
addButton
public void addButton(String name, SpellingBeeEventListener listener)
Adds a button to the control strip. When the user clicks the button, the implementation calls the listener function, passing in the name of the button.- Parameters:
name
- The name of the buttonlistener
- The listener called when the button is clicked
-
-