Package net.sf.freecol.client.gui.panel
Class NewPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- net.sf.freecol.client.gui.panel.MigPanel
-
- net.sf.freecol.client.gui.panel.FreeColPanel
-
- net.sf.freecol.client.gui.panel.NewPanel
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.ItemListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
public final class NewPanel extends FreeColPanel implements java.awt.event.ItemListener
This dialog allows the user to start a single player or multiplayer game, to join a running game, and to fetch a list of games from the meta-server.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
NewPanel.NewPanelAction
The actions for this panel.-
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
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JComboBox<NationOptions.Advantages>
advantagesBox
A box to choose the national advantages setting.private javax.swing.JLabel
advantagesLabel
The label for the national advantages.private javax.swing.ButtonGroup
buttonGroup
A button group for the main choices.private OptionGroup
difficulty
A current difficulty level, driven by the contents of the difficulty box..private javax.swing.JComboBox<OptionGroup>
difficultyBox
A box to choose the difficulty from.private javax.swing.JButton
difficultyButton
A button to show/edit difficulty level.private javax.swing.JLabel
difficultyLabel
A label for the difficulty level selection.private Specification
fixedSpecification
A particular specification to use for the new game.private java.awt.Component[]
gameComponents
Container for components to enable when choosing game parameters.private java.awt.Component[]
joinComponents
Container for the components to enable when Join is selected.private javax.swing.JTextField
joinNameField
Join multiplayer server name selection.private javax.swing.JLabel
joinNameLabel
Join multiplayer server name label.private javax.swing.JTextField
joinPortField
Join multiplayer server port selection.private javax.swing.JLabel
joinPortLabel
Join multiplayer server port label.private static java.util.logging.Logger
logger
private javax.swing.JTextField
nameBox
Field to input the player name.private javax.swing.JCheckBox
publicServer
The check box to select a public server with.private javax.swing.JComboBox<FreeColTcFile>
rulesBox
A box to choose the rules from.private javax.swing.JLabel
rulesLabel
The label for the rules selection.private javax.swing.JComboBox<java.net.InetAddress>
serverAddressBox
private java.awt.Component[]
serverComponents
Container for components to enable if server parameters can be set.private javax.swing.JTextField
serverPortField
Start server port number label and field to input through.private javax.swing.JLabel
serverPortLabel
Start server name label.private Specification
specification
The current specification, driven by the contents of the TC box.-
Fields inherited from class net.sf.freecol.client.gui.panel.FreeColPanel
CANCEL, editable, HELP, MARGIN, NL_SPAN_SPLIT_2, OK, okButton, SPAN_SPLIT_2
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description NewPanel(FreeColClient freeColClient)
Creates a new game panel.NewPanel(FreeColClient freeColClient, Specification specification)
Creates a new game panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent ae)
private boolean
checkDifficulty()
Check if the difficulty box changed.private boolean
checkTC()
Check if the TC changed.private void
enableComponents()
Enable components according to the selected button.private void
enableComponents(java.awt.Component[] components, boolean enable)
Dis/Enable a group of components.private NationOptions.Advantages
getSelectedAdvantages()
Gets the currently selected Advantages type from the nationalAdvantages box.private OptionGroup
getSelectedDifficulty()
Gets the currently selected difficulty from the difficultyBox.private java.lang.String
getSelectedName()
Get the selected player name from the nameBox.private int
getSelectedPort(javax.swing.JTextField field)
Get the value of a port field.private FreeColTcFile
getSelectedTC()
Gets the currently selected total-conversion from the rulesBox.Specification
getSpecification()
Get the specification.void
itemStateChanged(java.awt.event.ItemEvent e)
private void
update(boolean changed)
Update specification and difficulty as needed.private void
updateDifficultyBox()
Update just the difficulty box state.-
Methods inherited from class net.sf.freecol.client.gui.panel.FreeColPanel
addClosingCallback, createColonyButton, getClientOptions, getFreeColClient, getGame, getGUI, getImageLibrary, getMap, getMyPlayer, getSmallAbstractUnitImage, igc, isEditable, removeNotify, requestFocus, setCancelComponent
-
Methods inherited from class net.sf.freecol.client.gui.panel.MigPanel
getMigLayout, getUIClassID
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, 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, getBaseline, getBaselineResizeBehavior, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
fixedSpecification
private final Specification fixedSpecification
A particular specification to use for the new game. If not null, the specification box just contains this spec, but if null the user chooses from available specs using the specification box.
-
specification
private Specification specification
The current specification, driven by the contents of the TC box.
-
difficulty
private OptionGroup difficulty
A current difficulty level, driven by the contents of the difficulty box.. Difficulty levels are relative to the rules, so this can be invalidated by a change to the current specification.
-
nameBox
private final javax.swing.JTextField nameBox
Field to input the player name.
-
buttonGroup
private final javax.swing.ButtonGroup buttonGroup
A button group for the main choices.
-
advantagesLabel
private final javax.swing.JLabel advantagesLabel
The label for the national advantages.
-
advantagesBox
private final javax.swing.JComboBox<NationOptions.Advantages> advantagesBox
A box to choose the national advantages setting.
-
serverPortLabel
private final javax.swing.JLabel serverPortLabel
Start server name label.
-
serverPortField
private final javax.swing.JTextField serverPortField
Start server port number label and field to input through.
-
serverAddressBox
private final javax.swing.JComboBox<java.net.InetAddress> serverAddressBox
-
rulesLabel
private final javax.swing.JLabel rulesLabel
The label for the rules selection.
-
rulesBox
private final javax.swing.JComboBox<FreeColTcFile> rulesBox
A box to choose the rules from.
-
publicServer
private final javax.swing.JCheckBox publicServer
The check box to select a public server with.
-
difficultyLabel
private final javax.swing.JLabel difficultyLabel
A label for the difficulty level selection.
-
difficultyBox
private final javax.swing.JComboBox<OptionGroup> difficultyBox
A box to choose the difficulty from.
-
difficultyButton
private final javax.swing.JButton difficultyButton
A button to show/edit difficulty level.
-
joinNameLabel
private final javax.swing.JLabel joinNameLabel
Join multiplayer server name label.
-
joinNameField
private final javax.swing.JTextField joinNameField
Join multiplayer server name selection.
-
joinPortLabel
private final javax.swing.JLabel joinPortLabel
Join multiplayer server port label.
-
joinPortField
private final javax.swing.JTextField joinPortField
Join multiplayer server port selection.
-
joinComponents
private final java.awt.Component[] joinComponents
Container for the components to enable when Join is selected.
-
serverComponents
private final java.awt.Component[] serverComponents
Container for components to enable if server parameters can be set.
-
gameComponents
private final java.awt.Component[] gameComponents
Container for components to enable when choosing game parameters.
-
-
Constructor Detail
-
NewPanel
public NewPanel(FreeColClient freeColClient)
Creates a new game panel.- Parameters:
freeColClient
- TheFreeColClient
for the game.
-
NewPanel
public NewPanel(FreeColClient freeColClient, Specification specification)
Creates a new game panel.- Parameters:
freeColClient
- TheFreeColClient
for the game.specification
- An optionalSpecification
value for the new game.
-
-
Method Detail
-
update
private void update(boolean changed)
Update specification and difficulty as needed.- Parameters:
changed
- If true force an update.
-
checkTC
private boolean checkTC()
Check if the TC changed.- Returns:
- True if the TC changed.
-
checkDifficulty
private boolean checkDifficulty()
Check if the difficulty box changed.- Returns:
- True if the difficulty changed.
-
updateDifficultyBox
private void updateDifficultyBox()
Update just the difficulty box state.
-
getSelectedName
private java.lang.String getSelectedName()
Get the selected player name from the nameBox.- Returns:
- The selected player name.
-
getSelectedAdvantages
private NationOptions.Advantages getSelectedAdvantages()
Gets the currently selected Advantages type from the nationalAdvantages box.- Returns:
- The selected advantages type.
-
getSelectedTC
private FreeColTcFile getSelectedTC()
Gets the currently selected total-conversion from the rulesBox.- Returns:
- The selected TC.
-
getSelectedDifficulty
private OptionGroup getSelectedDifficulty()
Gets the currently selected difficulty from the difficultyBox.- Returns:
- The difficulty
OptionGroup
.
-
getSelectedPort
private int getSelectedPort(javax.swing.JTextField field)
Get the value of a port field.- Parameters:
field
- The field to read.- Returns:
- The port number in the field, or negative on error.
-
enableComponents
private void enableComponents()
Enable components according to the selected button.
-
enableComponents
private void enableComponents(java.awt.Component[] components, boolean enable)
Dis/Enable a group of components.- Parameters:
components
- TheComponent
s to set.enable
- Enable if true.
-
getSpecification
public Specification getSpecification()
Get the specification. Either the one set for this panel, or the one implied by the currently selected TC.- Overrides:
getSpecification
in classFreeColPanel
- Returns:
- The current
Specification
.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent ae)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- Overrides:
actionPerformed
in classFreeColPanel
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent e)
- Specified by:
itemStateChanged
in interfacejava.awt.event.ItemListener
-
-