|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Panel java.applet.Applet soc.client.SOCAccountClient
public class SOCAccountClient
Applet/Standalone client for connecting to the SOCServer and making user accounts. If you want another connection port, you have to specify it as the "port" argument in the html source. If you run this as a stand-alone, you have to specify the server's hostname and port on the command line.
Nested Class Summary | |
---|---|
private class |
SOCAccountClient.MyWindowAdapter
|
Nested classes/interfaces inherited from class java.applet.Applet |
---|
java.applet.Applet.AccessibleApplet |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
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 | |
---|---|
protected java.applet.AppletContext |
ac
|
protected java.awt.CardLayout |
cardLayout
|
(package private) java.util.Locale |
cliLocale
Locale for i18n message lookups used for strings . |
private java.awt.Button |
conn_cancel
Connect and Cancel buttons on connPanel . |
private java.awt.Button |
conn_connect
Connect and Cancel buttons on connPanel . |
private static java.lang.String |
CONN_PANEL
CardLayout string for connPanel . |
private java.awt.TextField |
conn_pass
Username, password, and status fields on connPanel . |
private boolean |
conn_sentAuth
If true, a username/password SOCAuthRequest has been sent to the server from connPanel . |
private java.awt.TextField |
conn_status
Username, password, and status fields on connPanel . |
private java.awt.TextField |
conn_user
Username, password, and status fields on connPanel . |
protected boolean |
connected
|
private java.awt.Panel |
connPanel
Connect and Authenticate panel ( CONN_PANEL ), for when
server needs authentication to create a user account. |
protected java.awt.TextField |
email
|
protected java.lang.String |
emailAddress
the email address |
protected java.lang.Exception |
ex
|
protected java.lang.String |
host
|
protected java.io.DataInputStream |
in
|
private static java.lang.String |
MAIN_PANEL
CardLayout string for the main panel while connected to a server: Has fields to enter nick , pass , etc,
status display and submit button. |
private static java.lang.String |
MESSAGE_PANEL
CardLayout string for the message panel when not connected to a server; message text is shown in messageLabel . |
protected java.awt.Label |
messageLabel
|
protected java.awt.TextField |
nick
|
private java.awt.Label |
nickLabel
Nickname field label. |
protected java.lang.String |
nickname
the nickname |
private AWTToolTip |
nickTTip
Nickname field tooltip reference, for use if its text must be updated. |
protected java.io.DataOutputStream |
out
|
protected java.awt.TextField |
pass
|
protected java.awt.TextField |
pass2
|
protected java.lang.String |
password
the password |
protected java.lang.String |
password2
the second password |
protected int |
port
|
private java.awt.Label |
promptLabel
Account info dialog prompt/label. |
protected java.lang.Thread |
reader
|
protected java.net.Socket |
s
|
protected SOCServerFeatures |
sFeatures
Server's active optional features, sent soon after connect, or null if unknown. |
static int |
SRV_VERSION_MIN
Minimum server version (v1.1.19) to which this account-management client will connect. |
protected java.awt.TextField |
status
|
private SOCStringManager |
strings
i18n text strings. |
protected java.awt.Button |
submit
|
protected boolean |
submitLock
|
protected int |
sVersion
Server version number for remote server, sent soon after connect. |
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 | |
---|---|
SOCAccountClient()
Create a SOCAccountClient connecting to localhost port 8880 |
|
SOCAccountClient(java.lang.String h,
int p)
Constructor for connecting to the specified host, on the specified port. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Handle mouse clicks and keyboard |
private void |
clickConnCancel()
Disconnect from connect/auth panel, show "disconnected" message. |
private void |
clickConnConnect()
"Connect" button, from connect/authenticate panel; check nickname & password fields, send auth request to server, set conn_sentAuth flag. |
void |
connect()
Attempts to connect to the server. |
private java.awt.event.WindowAdapter |
createWindowAdapter()
|
void |
destroy()
destroy the applet |
protected void |
disconnect()
disconnect from the net |
java.lang.String |
getAppletInfo()
applet info |
int |
getHexParameter(java.lang.String name)
Retrieve a parameter and translate to a hex value. |
protected void |
handleCHANNELS(SOCChannels mes)
Handle the "list of channels" message: Server connection is complete, show MAIN_PANEL unless connPanel is already showing. |
protected void |
handleREJECTCONNECTION(SOCRejectConnection mes)
handle the "reject connection" message |
protected void |
handleSTATUSMESSAGE(SOCStatusMessage mes)
handle the "status message" message. |
private void |
handleVERSION(SOCVersion mes)
Handle the "version" message: Server's version and feature report. |
void |
init()
Initialize the applet |
private void |
initInterface_conn()
Connect setup for username and password authentication: connPanel / CONN_PANEL . |
protected void |
initVisualElements()
init the visual elements at startup: MESSAGE_PANEL , MAIN_PANEL . |
void |
keyPressed(java.awt.event.KeyEvent e)
For Connect panel, handle Enter or Esc key (KeyListener). |
void |
keyReleased(java.awt.event.KeyEvent e)
Stub required by KeyListener |
void |
keyTyped(java.awt.event.KeyEvent e)
Stub required by KeyListener |
static void |
main(java.lang.String[] args)
for stand-alones |
boolean |
put(java.lang.String s)
write a message to the net |
void |
run()
continuously read from the net in a separate thread |
void |
treat(SOCMessage mes)
Treat the incoming messages |
private void |
updateLabelsIfNotOpenReg()
Update account-info label texts if needed. |
static void |
usage()
for stand-alones |
Methods inherited from class java.applet.Applet |
---|
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop |
Methods inherited from class java.awt.Panel |
---|
addNotify |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, 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, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, 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, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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 |
---|
public static final int SRV_VERSION_MIN
SOCServerFeatures
. Older clients can be downloaded or built from git release tags
to work with older servers.
Same format as Version.versionNumber()
.
Same value as SOCServerFeatures.VERSION_FOR_SERVERFEATURES
.
private static final java.lang.String MAIN_PANEL
nick
, pass
, etc,
status
display and submit
button.
private static final java.lang.String MESSAGE_PANEL
messageLabel
.
private static final java.lang.String CONN_PANEL
connPanel
.
private java.awt.Label promptLabel
private java.awt.Label nickLabel
private AWTToolTip nickTTip
protected java.awt.TextField nick
protected java.awt.TextField pass
protected java.awt.TextField pass2
protected java.awt.TextField email
protected java.awt.TextField status
protected java.awt.Button submit
protected java.awt.Label messageLabel
protected java.applet.AppletContext ac
protected boolean submitLock
private java.awt.Panel connPanel
CONN_PANEL
), for when
server needs authentication to create a user account.
Created in initInterface_conn()
.
private java.awt.TextField conn_user
connPanel
.
private java.awt.TextField conn_pass
connPanel
.
private java.awt.TextField conn_status
connPanel
.
private java.awt.Button conn_connect
connPanel
.
private java.awt.Button conn_cancel
connPanel
.
private boolean conn_sentAuth
SOCAuthRequest
has been sent to the server from connPanel
.
Used by handleSTATUSMESSAGE(SOCStatusMessage)
to show error results using connPanel
instead of the main panel.
protected java.awt.CardLayout cardLayout
protected java.lang.String host
protected int port
protected java.net.Socket s
protected java.io.DataInputStream in
protected java.io.DataOutputStream out
protected java.lang.Thread reader
protected java.lang.Exception ex
protected boolean connected
protected int sVersion
protected SOCServerFeatures sFeatures
protected java.lang.String nickname
protected java.lang.String password
protected java.lang.String password2
protected java.lang.String emailAddress
final java.util.Locale cliLocale
strings
.
Also sent to server when connecting.
Override if needed in the constructor by reading the
PROP_JSETTLERS_LOCALE
system property "jsettlers.locale"
.
private final SOCStringManager strings
cliLocale
.
Constructor Detail |
---|
public SOCAccountClient()
public SOCAccountClient(java.lang.String h, int p)
The SOCAccountClient
GUI's own localized strings use the
current user's default locale, unless overridden by setting the
PROP_JSETTLERS_LOCALE
system property "jsettlers.locale"
.
h
- hostp
- portMethod Detail |
---|
protected void initVisualElements()
MESSAGE_PANEL
, MAIN_PANEL
.
Labels' text assumes self-registration (Open Registration); if this is not the case
call updateLabelsIfNotOpenReg()
afterwards.
initInterface_conn()
private void initInterface_conn()
connPanel
/ CONN_PANEL
.
Called if server doesn't have SOCServerFeatures.FEAT_OPEN_REG
.
Calls Container.validate()
and conn_user
.requestFocus()
.
initVisualElements()
private void updateLabelsIfNotOpenReg()
initVisualElements()
has already been called.
public int getHexParameter(java.lang.String name)
name
- a parameter name. null is ignored
public void init()
init
in class java.applet.Applet
public void connect()
connected
for success or
failure.
java.lang.IllegalStateException
- if already connectedprivate void clickConnConnect()
conn_sentAuth
flag.
When the server responds with SOCStatusMessage.SV_OK
, the MAIN_PANEL
will be shown.
private void clickConnCancel()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public void run()
run
in interface java.lang.Runnable
public boolean put(java.lang.String s)
s
- the message
public void treat(SOCMessage mes)
mes
- the messageprivate void handleVERSION(SOCVersion mes)
SRV_VERSION_MIN
.
mes
- the messageprotected void handleCHANNELS(SOCChannels mes)
MAIN_PANEL
unless connPanel
is already showing.
mes
- the messageprotected void handleREJECTCONNECTION(SOCRejectConnection mes)
mes
- the messageprotected void handleSTATUSMESSAGE(SOCStatusMessage mes)
MAIN_PANEL
.
If we've just created a user (SOCStatusMessage.SV_ACCT_CREATED_OK
),
clear the password fields: must re-enter if creating another.
mes
- the messageprotected void disconnect()
public java.lang.String getAppletInfo()
getAppletInfo
in class java.applet.Applet
public void destroy()
destroy
in class java.applet.Applet
public static void usage()
public static void main(java.lang.String[] args)
private java.awt.event.WindowAdapter createWindowAdapter()
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |