|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
soc.client.SOCChoosePlayerDialog
class SOCChoosePlayerDialog
This is the dialog to ask a player from whom she wants to steal.
One button for each victim player. When a player is chosen,
send the server a choose-player command with that player number or
(if possible to choose none) SOCChoosePlayer.CHOICE_NO_PLAYER
.
For convenience with EventQueue.invokeLater(Runnable)
,
contains a run()
method which calls setVisible(true)
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Dialog |
---|
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType |
Nested classes/interfaces inherited from class java.awt.Window |
---|
java.awt.Window.AccessibleAWTWindow |
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
(package private) java.awt.Button[] |
buttons
Player names on each button. |
(package private) boolean |
didSetLocation
Flag to place window in center once when displayed (in doLayout() ),
and not change position again afterwards. |
private boolean |
hasCustomLayout
If true, doLayout() should manually lay out component locations. |
private static int |
MAX_ON_SAME_LINE
Maximum number of #players[] buttons to show on a single horizontal line. |
(package private) java.awt.Label |
msg
|
(package private) int |
number
Number of players to choose from for buttons and players . |
(package private) SOCPlayerInterface |
pi
|
(package private) java.awt.Label[] |
player_res_lbl
Show Count of resources of each player. |
(package private) int[] |
players
Player index of each to choose. |
private static SOCStringManager |
strings
i18n text strings; will use same locale as SOCPlayerClient's string manager. |
protected int |
wantH
Desired size (visible size inside of insets) |
protected int |
wantW
Desired size (visible size inside of insets) |
Fields inherited from class java.awt.Dialog |
---|
DEFAULT_MODALITY_TYPE |
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 | |
---|---|
SOCChoosePlayerDialog(SOCPlayerInterface plInt,
int num,
int[] p,
boolean allowChooseNone)
Creates a new SOCChoosePlayerDialog object. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
A button was clicked to choose a victim player. |
void |
doLayout()
Do our dialog's custom layout. |
void |
run()
Run method, for convenience with EventQueue.invokeLater(Runnable) . |
private void |
setLocationCentered(int width)
Put the dialog in the top-center of the game window ( pi )
and set didSetLocation . |
void |
setVisible(boolean b)
Show or hide this dialog. |
Methods inherited from class java.awt.Dialog |
---|
addNotify, getAccessibleContext, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setModalityType, setResizable, setTitle, setUndecorated, show, toBack |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final SOCStringManager strings
private static final int MAX_ON_SAME_LINE
#players[]
buttons to show on a single horizontal line.
If asking about more than this many players (including allowChooseNone
),
the layout will have each on its own line.
java.awt.Button[] buttons
players
. Length is number
.
If constructor is called with allowChooseNone
, there's a "decline" (choose none) button.
final int[] players
buttons
.
Only the first number
elements are used.
If constructor is called with allowChooseNone
, the "decline" button's
player number is -1 (SOCChoosePlayer.CHOICE_NO_PLAYER
).
java.awt.Label[] player_res_lbl
number
.
final int number
buttons
and players
.
final java.awt.Label msg
final SOCPlayerInterface pi
protected final int wantW
protected final int wantH
private final boolean hasCustomLayout
doLayout()
should manually lay out component locations.
See that method's javadoc for criteria.
boolean didSetLocation
doLayout()
),
and not change position again afterwards. Set in setLocationCentered(int)
.
Constructor Detail |
---|
public SOCChoosePlayerDialog(SOCPlayerInterface plInt, int num, int[] p, boolean allowChooseNone)
setVisible(boolean)
.
plInt
- PlayerInterface that owns this dialognum
- The number of players to choose fromp
- The player ids of those players; length of this
array may be larger than count (may be SOCGame.maxPlayers
).
Only the first num elements will be used.
If allowChooseNone, p.length must be at least num + 1
to leave room for "no player".allowChooseNone
- If true, player can choose to rob no one
(used with game scenario SC_PIRI
)Method Detail |
---|
public void setVisible(boolean b)
setVisible
in class java.awt.Dialog
b
- True to show, false to hidepublic void doLayout()
With 3 or fewer players[]
buttons, all buttons are on the same row:
Please choose a player to steal from: | ||
players[0] | players[1] | players[2] |
player_res_lbl[0] | player_res_lbl[1] | player_res_lbl[2] |
With 4 or more buttons, sharing a row would be too wide, so there is 1 player per row:
Please choose a player to steal from: | |
players[0] | player_res_lbl[0] |
players[1] | player_res_lbl[1] |
... | ... |
SC_PIRI
scenario, which allows
robbing any player with resources or declining to rob.
doLayout
in class java.awt.Container
private void setLocationCentered(int width)
pi
)
and set didSetLocation
.
width
- Dialog width if known, or 0public void actionPerformed(java.awt.event.ActionEvent e)
buttons
[i]
and send the server a choose-player command
with the corresponding player number players
[i].
actionPerformed
in interface java.awt.event.ActionListener
e
- AWT event, from a button sourcepublic void run()
EventQueue.invokeLater(Runnable)
.
This method just calls setVisible(true)
,
after calling Window.pack()
if applicable.
run
in interface java.lang.Runnable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |