public class ButtonListener extends Listener implements java.awt.event.ActionListener
addButtonListener method. When
the button event occurs, that object's appropriate
method is invoked.
Modifier and Type | Class and Description |
---|---|
private class |
ButtonListener.EmptyStringException
The Class EmptyStringException.
|
private class |
ButtonListener.ExcessWhitespaceException
This exception is thrown whenever there is excess white space in the text
input fields.
|
private class |
ButtonListener.MaximumAgeNegativeException
This exception is thrown whenever the maximum age in the maximum age
field is negative.
|
Constructor and Description |
---|
ButtonListener(OceanInterface model,
OceanGUIInterface view)
Instantiates a new button listener.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
This method gets an ActionEvent (with button was pressed) and execute the
specific code.
|
private void |
createObject(java.lang.String type,
java.lang.String name,
int maximumAge,
int[] position) |
private int |
getMaximumAge()
Gets the maximum age.
|
private java.lang.String |
getName() |
private java.lang.String |
getTypeOfObject()
Gets the type of object.
|
private int |
getXPosition()
Gets the x position.
|
private int |
getYPosition()
Gets the y position.
|
private void |
load(java.io.File nameLoad,
java.lang.String pathLoad)
This method loads an ocean from a file.
|
private void |
printBubbleThreadStates()
Prints out the state of each bubble generator thread,
for debugging purposes.
|
private void |
save(java.io.File nameSave,
java.lang.String pathSave)
This method saves an ocean to a file.
|
private void |
showOverview()
Print out a little ocean overview.
|
getMyOcean, getMyOceanGUI, message, repaintOcean, setMyModel, setMyView, sleep, updateGUI, updateStatusPanel
public ButtonListener(OceanInterface model, OceanGUIInterface view)
model
- the modelview
- the viewpublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- the action event that provides the info which button was
pressed.private void createObject(java.lang.String type, java.lang.String name, int maximumAge, int[] position) throws java.lang.Exception
type
- a String describing the type of OceanObject to createname
- a String containing the name for the objectmaximumAge
- an integer specifying the maximum ageposition
- java.lang.Exception
- Create an new OceanObject, by type.private int getMaximumAge()
private java.lang.String getName()
private java.lang.String getTypeOfObject()
private int getXPosition()
private int getYPosition()
private void load(java.io.File nameLoad, java.lang.String pathLoad)
nameLoad
- a String containig the file name.pathLoad
- a String containig the path to the file.private void printBubbleThreadStates()
private void save(java.io.File nameSave, java.lang.String pathSave)
nameSave
- a String containig the file name.pathSave
- a String containig the path to the file.private void showOverview()