game
Class Main
java.lang.Object
nip.Tool
game.Main
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener
public class Main
- extends nip.Tool
This class adapts mouse actions and tells the Controller what to do.
- Author:
- Ron Cytron
| Fields inherited from class nip.Tool |
nip |
|
Constructor Summary |
Main()
|
|
Method Summary |
void |
actionNameCalled(java.lang.String name)
When a command in the Method menu is pressed in the NIP instance, this
method is called, with the parameter corresponding to the name of the
command clicked upon (this will be one of the Strings in the array returned
by getEventNames). |
java.lang.String[] |
getEventNames()
This method returns an array of Strings which correspond to the names of
commands that will appear in the NIP Methods menu. |
static void |
main(java.lang.String[] args)
|
void |
mouseClicked(java.awt.event.MouseEvent me)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent me)
When the mouse moves, inform the Controller
to set its Paddle at the specified location. |
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
java.lang.String |
toString()
|
| Methods inherited from class nip.Tool |
actionPerformed, mouseEntered, mouseExited |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Main
public Main()
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent me)
- Specified by:
mouseClicked in interface java.awt.event.MouseListener- Overrides:
mouseClicked in class nip.Tool
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent me)
- When the mouse moves, inform the Controller
to set its Paddle at the specified location.
- Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener- Overrides:
mouseMoved in class nip.Tool
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed in interface java.awt.event.MouseListener- Overrides:
mousePressed in class nip.Tool
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener- Overrides:
mouseDragged in class nip.Tool
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased in interface java.awt.event.MouseListener- Overrides:
mouseReleased in class nip.Tool
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
actionNameCalled
public void actionNameCalled(java.lang.String name)
- Description copied from class:
nip.Tool
- When a command in the Method menu is pressed in the NIP instance, this
method is called, with the parameter corresponding to the name of the
command clicked upon (this will be one of the Strings in the array returned
by getEventNames). The implementation of this class will determine how
the tool should respond when a command is pressed. It can be implemented by
a chain of if-else if branches, one corresponding to each possible command.
- Specified by:
actionNameCalled in class nip.Tool
getEventNames
public java.lang.String[] getEventNames()
- Description copied from class:
nip.Tool
- This method returns an array of Strings which correspond to the names of
commands that will appear in the NIP Methods menu. The names need not
be related to method names, but should be as self-explanatory as possible.
This method is most easily implemented as follows:
return new String[] = {"Option 1", "Option 2", ...};
Note: To avoid errors, a method that wishes to display no methods in the
Methods menu should return a new String[0]() instead of null.
- Specified by:
getEventNames in class nip.Tool
- Returns:
- An array of String objects containing the names of commands.
main
public static void main(java.lang.String[] args)