public class MenuItem
extends java.lang.Object
implements java.lang.Runnable
Menu
class.Menu
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
displayString |
protected boolean |
exit |
Modifier | Constructor and Description |
---|---|
protected |
MenuItem()
Constructor for derived classes.
|
|
MenuItem(java.lang.String displayString)
Constructor for using this class for a generic menu entry.
|
|
MenuItem(java.lang.String displayString,
boolean exitAfterSelect)
Constructor for using this class for a generic menu entry.
|
Modifier and Type | Method and Description |
---|---|
boolean |
exitAfterRun()
Return
true if the Menu should be exited after
the MenuItem has been selected and run. |
java.lang.String |
getDisplayString()
Return the string to display as the menu choice.
|
void |
run()
Called when
MenuItem is selected by the user. |
protected MenuItem()
Derived classes must override exitAfterRun() if they want
it to return true
;
public MenuItem(java.lang.String displayString)
true
from
exitAfterRun()
.displayString
- menu item textpublic MenuItem(java.lang.String displayString, boolean exitAfterSelect)
displayString
- menu item textexitAfterSelect
- value that exitAfterRun()
will return.public void run()
MenuItem
is selected by the user.
Default implementation does nothing.
run
in interface java.lang.Runnable
public java.lang.String getDisplayString()
public boolean exitAfterRun()
true
if the Menu
should be exited after
the MenuItem
has been selected and run.true
if Menu
should exit after run()
is called.