Class Chatlet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--Chatlet
All Implemented Interfaces:
javax.accessibility.Accessible, ConnectionHandler, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class Chatlet
extends java.applet.Applet
implements ConnectionHandler

This is the Chatlet applet. It a simple user interface with a common IRC client styled layout.

See Also:
Serialized Form

Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static char bold
          Bold delimiter.
static char color
          Color delimiter.
static char reverse
          Reverse delimiter.
static char underline
          Underline delimiter.
 
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
Chatlet()
           
 
Method Summary
 void append(java.lang.String str)
          Used to append a String to the textfield in the chat.
 void beep()
          Used to sound the system bell.
 java.lang.String colorName(int cidx)
          Gets the name of a color with a certain index.
 void execute(java.lang.String data)
          Used to execute a command sent to the client from the servlet.
 java.lang.Object getConnectionData()
          Used when handshaking to get the connection data.
 void handleData(java.lang.Object data)
          Used to handle data recieved by the ServletConnection.
 java.awt.Color hexColor(java.lang.String hexString)
          Used to convert a color string (fe84c2) to a Color object.
 void init()
          The initalization of the Chatlet is done here.
 boolean isConnected()
          Used to retrieve the current connection status.
 java.lang.String parse(java.lang.String str)
          Used to parse color and bold controls in the incoming message.
 void setConnected(boolean connected)
          Used to set the connection status.
 void setConnectionResponse(java.lang.Object response)
          The response given in a handshake procedure.
 void start()
          Reinitialize some things when started/restarted.
 void stop()
          When the applet is stopped a disconnection is forced.
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

reverse

public static final char reverse
Reverse delimiter.

underline

public static final char underline
Underline delimiter.

color

public static final char color
Color delimiter.

bold

public static final char bold
Bold delimiter.
Constructor Detail

Chatlet

public Chatlet()
Method Detail

hexColor

public java.awt.Color hexColor(java.lang.String hexString)
Used to convert a color string (fe84c2) to a Color object.
Parameters:
hexString - The color given as a string of eight hexadecimal digits.

init

public void init()
The initalization of the Chatlet is done here. Parameters are read from the HTML code and then the layout is done using those values.
Overrides:
init in class java.applet.Applet

start

public void start()
Reinitialize some things when started/restarted.
Overrides:
start in class java.applet.Applet

stop

public void stop()
When the applet is stopped a disconnection is forced.
Overrides:
stop in class java.applet.Applet

beep

public void beep()
Used to sound the system bell.

append

public void append(java.lang.String str)
Used to append a String to the textfield in the chat.
Parameters:
str - The String to be appended.

getConnectionData

public java.lang.Object getConnectionData()
Used when handshaking to get the connection data.
Specified by:
getConnectionData in interface ConnectionHandler
Returns:
The connection data to use when handshaking.

setConnectionResponse

public void setConnectionResponse(java.lang.Object response)
The response given in a handshake procedure.
Specified by:
setConnectionResponse in interface ConnectionHandler
Parameters:
response - The response from a handshake.

isConnected

public boolean isConnected()
Used to retrieve the current connection status.
Specified by:
isConnected in interface ConnectionHandler
Returns:
true when a connection has been established and false otherwise.

setConnected

public void setConnected(boolean connected)
Used to set the connection status.
Specified by:
setConnected in interface ConnectionHandler
Parameters:
connected - true or false.

handleData

public void handleData(java.lang.Object data)
Used to handle data recieved by the ServletConnection.
Specified by:
handleData in interface ConnectionHandler
Parameters:
data - The data to be handled.

execute

public void execute(java.lang.String data)
Used to execute a command sent to the client from the servlet.
Parameters:
data - The command data from the server.

parse

public java.lang.String parse(java.lang.String str)
                       throws java.lang.NumberFormatException
Used to parse color and bold controls in the incoming message.
Parameters:
str - The unparsed String.
Returns:
A String where color and bold controls has been parsed.

colorName

public java.lang.String colorName(int cidx)
Gets the name of a color with a certain index.
Parameters:
cidx - The index of the color.
Returns:
The name of the color as a String.