|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public static interface SOCGameOption.ChangeListener
Listener for option value changes at the client during game creation. When the user changes an option, allows a related option to change. For example, when the max players is changed to 5 or 6, the listener can check the box for "use 6-player board".
Once written, a newer server can't do anything to update an older client's ChangeListener code, so be careful and write them defensively.
Callback method is valueChanged(SOCGameOption, Object, Object, Map)
.
Called from NewGameOptionsFrame.
For server-side consistency adjustment of values before creating games,
add code to SOCGameOption.adjustOptionsToKnown(Map, Map, boolean)
that's equivalent to your ChangeListener.
SOCGameOption.addChangeListener(ChangeListener)
Method Summary | |
---|---|
void |
valueChanged(SOCGameOption opt,
java.lang.Object oldValue,
java.lang.Object newValue,
java.util.Map<java.lang.String,SOCGameOption> currentOpts)
Called when the user changes opt's value during game creation. |
Method Detail |
---|
void valueChanged(SOCGameOption opt, java.lang.Object oldValue, java.lang.Object newValue, java.util.Map<java.lang.String,SOCGameOption> currentOpts)
If you change any other currentOpts values,
be sure to call SOCGameOption.refreshDisplay()
to update the GUI.
Do not call refreshDisplay() on opt.
Remember that the related option may not be present in currentOpts because different servers may have different default options, or different versions.
Write this method carefully, because the server can't update a client's
buggy version. Although calls to this method are surrounded by a try/catch(Throwable
)
block, a bug-free version is best for the user.
For SOCGameOption.OTYPE_STR
or OTYPE_STRHIDE, this method is
called once for each character entered or deleted.
For SOCGameOption.OTYPE_INT
or OTYPE_INTBOOL, this method is
called once for each digit typed or deleted, so long as the resulting number
is parsable and within the min/max range for the option.
For SOCGameOption.OTYPE_ENUMBOOL
or OTYPE_INTBOOL, if both the
boolean and int value fields are set at once, then after updating both fields,
valueChanged will be called twice (boolean and then int).
If the boolean value is cleared to false, there won't be a second call for the
int value, because when cleared the game option has no effect.
opt
- Option that has changed, already updated to new valueoldValue
- Old value; an Integer, Boolean, or String.newValue
- New value; always the same class as oldValuecurrentOpts
- The current value of all SOCGameOption
s in this set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |