Package edu.willamette.cs1.wordle
Class WordleGWindow
- Object
-
- edu.willamette.cs1.wordle.WordleGWindow
-
public class WordleGWindow extends Object
This class implements graphics for the Wordle assignment.
-
-
Field Summary
Fields Modifier and Type Field Description static Color
CORRECT_COLOR
The color used for correct letters (a light green).static Color
MISSING_COLOR
The color used for letters that are missing (a medium gray).static int
N_COLS
The number of columns in the Wordle grid.static int
N_ROWS
The number of rows in the Wordle grid.static Color
PRESENT_COLOR
The color used for letters that are present (a brownish yellow).
-
Constructor Summary
Constructors Constructor Description WordleGWindow()
Creates a new WordleGWindow object and displays it on the screen.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEnterListener(WordleEventListener listener)
Adds an event listener to the window, which in this application is triggered by hitting the RETURN key or pressing the ENTER button.int
getCurrentRow()
Gets the current row number.Color
getKeyColor(String label)
Returns the background color for the key with the specified label.Color
getSquareColor(int row, int col)
Returns the background color for the grid square at the specified row and column.String
getSquareLetter(int row, int col)
Returns the label from the grid square at the specified row and column.void
setCurrentRow(int row)
Sets the current row number and clears all the squares on that row.void
setKeyColor(String label, Color color)
Sets the background color of the key with the specified label.void
setSquareColor(int row, int col, Color color)
Sets the background color of the grid square at the specified row and column.void
setSquareLetter(int row, int col, String letter)
Sets the label from the grid square at the specified row and column.void
showMessage(String msg)
Displays a message under the board grid.
-
-
-
Field Detail
-
N_ROWS
public static final int N_ROWS
The number of rows in the Wordle grid.- See Also:
- Constant Field Values
-
N_COLS
public static final int N_COLS
The number of columns in the Wordle grid.- See Also:
- Constant Field Values
-
CORRECT_COLOR
public static final Color CORRECT_COLOR
The color used for correct letters (a light green).
-
PRESENT_COLOR
public static final Color PRESENT_COLOR
The color used for letters that are present (a brownish yellow).
-
MISSING_COLOR
public static final Color MISSING_COLOR
The color used for letters that are missing (a medium gray).
-
-
Method Detail
-
setSquareLetter
public void setSquareLetter(int row, int col, String letter)
Sets the label from the grid square at the specified row and column.- Parameters:
row
- The zero-based row numbercol
- The zero-based column numberletter
- The new contents of the square as a string
-
getSquareLetter
public String getSquareLetter(int row, int col)
Returns the label from the grid square at the specified row and column.- Parameters:
row
- The zero-based row numbercol
- The zero-based column number- Returns:
- The contents of the square as a string
-
setSquareColor
public void setSquareColor(int row, int col, Color color)
Sets the background color of the grid square at the specified row and column. Colors are represented as strings in the form "#rrggbb".- Parameters:
row
- The zero-based row numbercol
- The zero-based column numbercolor
- The new color of the grid square
-
getSquareColor
public Color getSquareColor(int row, int col)
Returns the background color for the grid square at the specified row and column.- Parameters:
row
- The zero-based row numbercol
- The zero-based column number- Returns:
- The background color of the square
-
setKeyColor
public void setKeyColor(String label, Color color)
Sets the background color of the key with the specified label. Colors are represented as strings in the form "#rrggbb".- Parameters:
label
- The label on the keycolor
- The new color of the grid square as a string
-
getKeyColor
public Color getKeyColor(String label)
Returns the background color for the key with the specified label.- Parameters:
label
- The label on the key- Returns:
- The background color of the square
-
setCurrentRow
public void setCurrentRow(int row)
Sets the current row number and clears all the squares on that row.- Parameters:
row
- The new row number
-
getCurrentRow
public int getCurrentRow()
Gets the current row number.- Returns:
- The row number
-
showMessage
public void showMessage(String msg)
Displays a message under the board grid.- Parameters:
msg
- The text of the message
-
addEnterListener
public void addEnterListener(WordleEventListener listener)
Adds an event listener to the window, which in this application is triggered by hitting the RETURN key or pressing the ENTER button.- Parameters:
listener
- The WordleEventListener waiting for this event
-
-