net.sf.freecol.client.gui.panel
Class FreeColDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.sf.freecol.client.gui.panel.FreeColPanel
                      extended by net.sf.freecol.client.gui.panel.FreeColDialog
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
CaptureGoodsDialog, ChooseFoundingFatherDialog, ClientOptionsDialog, DeclarationDialog, EmigrationPanel, ErrorPanel, EventPanel, GameOptionsDialog, IndianSettlementPanel, LoadingSavegameDialog, MapGeneratorOptionsDialog, MonarchPanel, PurchaseDialog, QuitDialog, RecruitDialog, TilePanel, TradeRouteDialog, TradeRouteInputDialog, TrainDialog, WarehouseDialog

public class FreeColDialog
extends FreeColPanel

Superclass for all dialogs in FreeCol. This class also contains methods to create simple dialogs.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String LICENSE
           
static int MISSIONARY_CANCEL
           
static int MISSIONARY_DENOUNCE_AS_HERESY
           
static int MISSIONARY_ESTABLISH
           
static int MISSIONARY_INCITE_INDIANS
           
static java.lang.String REVISION
           
static int SCOUT_INDIAN_SETTLEMENT_ATTACK
           
static int SCOUT_INDIAN_SETTLEMENT_CANCEL
           
static int SCOUT_INDIAN_SETTLEMENT_SPEAK
           
static int SCOUT_INDIAN_SETTLEMENT_TRIBUTE
           
 
Fields inherited from class net.sf.freecol.client.gui.panel.FreeColPanel
bigHeaderFont, columns, defaultFont, higConst, margin, mediumHeaderFont, smallHeaderFont
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FreeColDialog()
          Default constructor.
FreeColDialog(Canvas parent)
          Constructor.
 
Method Summary
static FreeColDialog createArmedUnitIndianSettlementDialog(IndianSettlement settlement, Player player)
          Creates a dialog that asks the user what he wants to do with his scout in the indian settlement.
static FreeColDialog createChoiceDialog(java.lang.String text, java.lang.String cancelText, java.lang.Object[] objects)
          Creates a new FreeColDialog with a text and a cancel-button, in addition to buttons for each of the objects in the given array.
static FreeColDialog createConfirmDialog(java.lang.String[] texts, javax.swing.ImageIcon[] images, java.lang.String okText, java.lang.String cancelText)
           
static FreeColDialog createConfirmDialog(java.lang.String text, java.lang.String okText, java.lang.String cancelText)
          Creates a new FreeColDialog with a text and a ok/cancel option.
static FreeColDialog createInciteDialog(java.util.Vector<Player> allPlayers, Player thisUser)
          Creates a dialog that asks the user which player he wants the indians to attack.
static FreeColDialog createInformationDialog(java.lang.String[] texts, javax.swing.ImageIcon[] images)
          Returns an information dialog that shows the given texts and images, and an "OK" button.
static FreeColDialog createInformationDialog(java.lang.String text, java.lang.String okText)
          Creates a new FreeColDialog with a text and an ok-button.
static FreeColDialog createInformationDialog(java.lang.String text, java.lang.String okText, javax.swing.ImageIcon image)
          Creates a new FreeColDialog with a text and an ok-button.
static FreeColDialog createInputDialog(java.lang.String text, java.lang.String defaultValue, java.lang.String okText, java.lang.String cancelText)
          Creates a new FreeColDialog with a text field and a ok/cancel option.
static FreeColDialog createLoadDialog(java.io.File directory, javax.swing.filechooser.FileFilter[] fileFilters)
          Creates a new FreeColDialog in which the user may choose a savegame to load.
static FreeColDialog createPreCombatDialog(Unit attacker, Unit defender, Settlement settlement, Canvas parent)
           
static FreeColDialog createSaveDialog(java.io.File directory, java.lang.String standardName, javax.swing.filechooser.FileFilter[] fileFilters, java.lang.String defaultName)
          Creates a new FreeColDialog in which the user may choose the destination of the savegame.
static FreeColDialog createScoutIndianSettlementDialog(IndianSettlement settlement, Player player)
          Creates a dialog that asks the user what he wants to do with his scout in the indian settlement.
static FreeColDialog createUseMissionaryDialog(IndianSettlement settlement, Player player)
          Creates a dialog that asks the user what he wants to do with his missionary in the indian settlement.
static javax.swing.filechooser.FileFilter getFGOFileFilter()
          Returns a filter accepting "*.fgo".
static javax.swing.filechooser.FileFilter getFSGFileFilter()
          Returns a filter accepting "*.fsg".
static javax.swing.filechooser.FileFilter getGameOptionsFileFilter()
          Returns a filter accepting all files containing a GameOptions.
 java.lang.Object getResponse()
          Returns the response when set by setResponse(Object response).
 boolean getResponseBoolean()
          Convenience method for getResponse().
 int getResponseInt()
          Convenience method for getResponse().
 void resetResponse()
          Sets that no response has been given.
 void setResponse(java.lang.Object response)
          Sets the response and wakes up any thread waiting for this information.
 
Methods inherited from class net.sf.freecol.client.gui.panel.FreeColPanel
enterPressesWhenFocused, getCanvas, getDefaultHeader, getDefaultTextArea, setCancelComponent
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

LICENSE

public static final java.lang.String LICENSE
See Also:
Constant Field Values

REVISION

public static final java.lang.String REVISION
See Also:
Constant Field Values

SCOUT_INDIAN_SETTLEMENT_CANCEL

public static final int SCOUT_INDIAN_SETTLEMENT_CANCEL
See Also:
Constant Field Values

SCOUT_INDIAN_SETTLEMENT_SPEAK

public static final int SCOUT_INDIAN_SETTLEMENT_SPEAK
See Also:
Constant Field Values

SCOUT_INDIAN_SETTLEMENT_TRIBUTE

public static final int SCOUT_INDIAN_SETTLEMENT_TRIBUTE
See Also:
Constant Field Values

SCOUT_INDIAN_SETTLEMENT_ATTACK

public static final int SCOUT_INDIAN_SETTLEMENT_ATTACK
See Also:
Constant Field Values

MISSIONARY_CANCEL

public static final int MISSIONARY_CANCEL
See Also:
Constant Field Values

MISSIONARY_ESTABLISH

public static final int MISSIONARY_ESTABLISH
See Also:
Constant Field Values

MISSIONARY_DENOUNCE_AS_HERESY

public static final int MISSIONARY_DENOUNCE_AS_HERESY
See Also:
Constant Field Values

MISSIONARY_INCITE_INDIANS

public static final int MISSIONARY_INCITE_INDIANS
See Also:
Constant Field Values
Constructor Detail

FreeColDialog

public FreeColDialog()
Default constructor.


FreeColDialog

public FreeColDialog(Canvas parent)
Constructor.

Method Detail

setResponse

public void setResponse(java.lang.Object response)
Sets the response and wakes up any thread waiting for this information.

Parameters:
response - The object that should be returned by getResponse().

getResponse

public java.lang.Object getResponse()
Returns the response when set by setResponse(Object response). Waits the thread until then.

Returns:
The object as set by setResponse(java.lang.Object).

getResponseBoolean

public boolean getResponseBoolean()
Convenience method for getResponse().

Returns:
The response as a boolean.
Throws:
java.lang.ClassCastException - if the response-object is not of type Boolean.

getResponseInt

public int getResponseInt()
Convenience method for getResponse().

Returns:
The response as a int.
Throws:
java.lang.ClassCastException - if the response-object is not of type Integer.

resetResponse

public void resetResponse()
Sets that no response has been given.


createInformationDialog

public static FreeColDialog createInformationDialog(java.lang.String text,
                                                    java.lang.String okText)
Creates a new FreeColDialog with a text and an ok-button. The "ok"-option calls setResponse(new Boolean(true)).

Parameters:
text - The text that explains the choice for the user.
okText - The text displayed on the "ok"-button.
Returns:
The FreeColDialog.

createInformationDialog

public static FreeColDialog createInformationDialog(java.lang.String text,
                                                    java.lang.String okText,
                                                    javax.swing.ImageIcon image)
Creates a new FreeColDialog with a text and an ok-button. The "ok"-option calls setResponse(new Boolean(true)).

Parameters:
text - The text that explains the choice for the user.
okText - The text displayed on the "ok"-button.
image - The image to be displayed.
Returns:
The FreeColDialog.

createInformationDialog

public static FreeColDialog createInformationDialog(java.lang.String[] texts,
                                                    javax.swing.ImageIcon[] images)
Returns an information dialog that shows the given texts and images, and an "OK" button.

Parameters:
texts - The texts to be displayed in the dialog.
images - The images to be displayed in the dialog.
Returns:
An information dialog that shows the given text and an "OK" button.

createPreCombatDialog

public static FreeColDialog createPreCombatDialog(Unit attacker,
                                                  Unit defender,
                                                  Settlement settlement,
                                                  Canvas parent)

createChoiceDialog

public static FreeColDialog createChoiceDialog(java.lang.String text,
                                               java.lang.String cancelText,
                                               java.lang.Object[] objects)
Creates a new FreeColDialog with a text and a cancel-button, in addition to buttons for each of the objects in the given array.

Parameters:
text - The text that explains the choice for the user.
cancelText - The text displayed on the "cancel"-button.
objects - The objects.
Returns:
The FreeColDialog.
See Also:
ChoiceItem

createConfirmDialog

public static FreeColDialog createConfirmDialog(java.lang.String text,
                                                java.lang.String okText,
                                                java.lang.String cancelText)
Creates a new FreeColDialog with a text and a ok/cancel option. The "ok"-option calls setResponse(new Boolean(true)) and the "cancel"-option calls setResponse(new Boolean(false)).

Parameters:
text - The text that explains the choice for the user.
okText - The text displayed on the "ok"-button.
cancelText - The text displayed on the "cancel"-button.
Returns:
The FreeColDialog.

createConfirmDialog

public static FreeColDialog createConfirmDialog(java.lang.String[] texts,
                                                javax.swing.ImageIcon[] images,
                                                java.lang.String okText,
                                                java.lang.String cancelText)

createScoutIndianSettlementDialog

public static FreeColDialog createScoutIndianSettlementDialog(IndianSettlement settlement,
                                                              Player player)
Creates a dialog that asks the user what he wants to do with his scout in the indian settlement. Options are: speak with chief, demand tribute, attack or cancel. The possible responses are integers that are defined in this class as finals.

Parameters:
settlement - The indian settlement that is being scouted.
player - The player to create the dialog for.
Returns:
The FreeColDialog that asks the question to the user.

createArmedUnitIndianSettlementDialog

public static FreeColDialog createArmedUnitIndianSettlementDialog(IndianSettlement settlement,
                                                                  Player player)
Creates a dialog that asks the user what he wants to do with his scout in the indian settlement. Options are: speak with chief, demand tribute, attack or cancel. The possible responses are integers that are defined in this class as finals.

Parameters:
settlement - The indian settlement that is being scouted.
player - The player to create the dialog for.
Returns:
The FreeColDialog that asks the question to the user.

createUseMissionaryDialog

public static FreeColDialog createUseMissionaryDialog(IndianSettlement settlement,
                                                      Player player)
Creates a dialog that asks the user what he wants to do with his missionary in the indian settlement. Options are: establish mission, denounce existing (foreign) mission as heresy, incite indians (request them to attack other European player) or cancel. The possible responses are integers that are defined in this class as finals.

Parameters:
settlement - The indian settlement that is being visited.
player - The Player to create the dialog for.
Returns:
The FreeColDialog that asks the question to the user.

createInciteDialog

public static FreeColDialog createInciteDialog(java.util.Vector<Player> allPlayers,
                                               Player thisUser)
Creates a dialog that asks the user which player he wants the indians to attack. All the players will be shown as options (not including the current player of course). The possible responses are Player objects that that represent a player that should be attacked.

Parameters:
allPlayers - All players in the game.
thisUser - The current player.
Returns:
The FreeColDialog that asks the question to the user.

createInputDialog

public static FreeColDialog createInputDialog(java.lang.String text,
                                              java.lang.String defaultValue,
                                              java.lang.String okText,
                                              java.lang.String cancelText)
Creates a new FreeColDialog with a text field and a ok/cancel option. The "ok"-option calls setResponse(textField.getText()) and the "cancel"-option calls setResponse(null).

Parameters:
text - The text that explains the action to the user.
defaultValue - The default value appearing in the text field.
okText - The text displayed on the "ok"-button.
cancelText - The text displayed on the "cancel"-button.
Returns:
The FreeColDialog.

createLoadDialog

public static FreeColDialog createLoadDialog(java.io.File directory,
                                             javax.swing.filechooser.FileFilter[] fileFilters)
Creates a new FreeColDialog in which the user may choose a savegame to load.

Parameters:
directory - The directory to display when choosing the file.
fileFilters - The available file filters in the dialog.
Returns:
The FreeColDialog.

createSaveDialog

public static FreeColDialog createSaveDialog(java.io.File directory,
                                             java.lang.String standardName,
                                             javax.swing.filechooser.FileFilter[] fileFilters,
                                             java.lang.String defaultName)
Creates a new FreeColDialog in which the user may choose the destination of the savegame.

Parameters:
directory - The directory to display when choosing the name.
standardName - This extension will be added to the specified filename (if not added by the user).
fileFilters - The available file filters in the dialog.
defaultName - Default filename for the savegame.
Returns:
The FreeColDialog.

getFSGFileFilter

public static javax.swing.filechooser.FileFilter getFSGFileFilter()
Returns a filter accepting "*.fsg".

Returns:
The filter.

getFGOFileFilter

public static javax.swing.filechooser.FileFilter getFGOFileFilter()
Returns a filter accepting "*.fgo".

Returns:
The filter.

getGameOptionsFileFilter

public static javax.swing.filechooser.FileFilter getGameOptionsFileFilter()
Returns a filter accepting all files containing a GameOptions. That is; both "*.fgo" and "*.fsg".

Returns:
The filter.