All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.monpetitcoin.java.PrisonerGame.PrisonerGame. OptionsDialog

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Dialog
                                   |
                                   +----com.monpetitcoin.java.PrisonerGame.PrisonerGame.OptionsDialog

private class PrisonerGame. OptionsDialog
extends java.awt.Dialog
implements java.awt.event.ActionListener
This inner class displays a dialog box with the options of a Prisoner's Dilemma game that can be set by the user, i.e.

The dialog also displays a warning that changing any of the above parameters (except the refresh frequency) restarts the game.

Version:
1.00, 15 August 2001
Author:
François Suter

Class Index

 o PrisonerGame.1

Variable Index

 o cancelButton
 o gainField
 o heightField
 o okButton
 o refreshField
 o thresholdField
 o widthField

Constructor Index

 o PrisonerGame.OptionsDialog(PrisonerGame, Frame, String)
The constructor lays out the elements of the dialog box in a GridBagLayout and registers the needed listeners.

Method Index

 o actionPerformed(ActionEvent)
When the "OK" button is pressed, this method invokes the applyOptions() method.
 o applyOptions()
This method is used to apply the new options defined by the user.

Variables

 o cancelButton
 private java.awt.Button cancelButton
 o okButton
 private java.awt.Button okButton
 o widthField
 private java.awt.TextField widthField
 o heightField
 private java.awt.TextField heightField
 o gainField
 private java.awt.TextField gainField
 o thresholdField
 private java.awt.TextField thresholdField
 o refreshField
 private java.awt.TextField refreshField

Constructors

 o PrisonerGame.OptionsDialog
 public PrisonerGame.OptionsDialog(com.monpetitcoin.java.PrisonerGame.PrisonerGame this$0,
                                   java.awt.Frame parent,
                                   java.lang.String title)
The constructor lays out the elements of the dialog box in a GridBagLayout and registers the needed listeners.

Parameters:
parent - The parent frame calling the dialog box
title - A String containing the title of the window
See Also:
sofiae.util.TextCanvas

Methods

 o applyOptions
 private boolean applyOptions()
This method is used to apply the new options defined by the user. It tries to parse all text fields into int or double values. If any of these values are different from the current ones, the game is restarted by invoking the restartGame() method of the parent PrisonerGame instance. A format error in a number calls up an alert window. If only the refresh frequency was changed, the game is not restarted. The new value is just set and any running PrisonerGame takes it in stride (note that the setRefreshFrequency() method is synchronized). return The method returns false if an error occured

See Also:
sofiae.util.AlertWindow, restartGame, setRefreshFrequency
 o actionPerformed
 public void actionPerformed(java.awt.event.ActionEvent e)
When the "OK" button is pressed, this method invokes the applyOptions() method. If the latter returns true or the "Cancel" button was pressed, the dialog box is disposed of.


All Packages  Class Hierarchy  This Package  Previous  Next  Index