Class ChatWindow

java.lang.Object
  |
  +--ChatWindow

public class ChatWindow
extends java.lang.Object

A ChatWindow is a window which handles the user interaction of one active chat session. The window consists of two main parts. The upper part of the window consists of a scrollable text field into which incoming messages (as well as your own) can be written. The text field is read-only to the user. The lower part of the window consists of a single-line input field into which the user can type his own, out-going, messages. A button which can be used to submit the text in the input field to the chat system is located next to the input field.

Input, that is messages entered into the input field, is handled by the messageEntered method which is called automatically whenever the user clicks on the submit button. The intention is that the ChatWindow class should be used as a super class to another class which overloads the messageEntered method. The overloaded method should contain the Java code to be executed when a new message is entered. Another possible way of using the class is to modify the ChatWindow class directly, putting the code to be executed when a new message is entered directly in the messageEntered method.


Constructor Summary
ChatWindow(int x, int y, java.lang.String title)
          Constructs a ChatWindow at a given position on the screen and with a given title which is displayed in the title bar of the window.
 
Method Summary
 void add(java.lang.String message)
          Adds a new message to the message area in the upper part of the ChatWindow.
 void clear()
          Clears the contents of the message area in the upper part of the ChatWindow.
 void destroy()
          Destroys the ChatWindow and frees all resources associated with it.
 void hide()
          Makes the ChatWindow invisible.
 void messageEntered(java.lang.String message)
          The messageEntered method is called whenever the user submits a new message and controls how to handle the new message.
 void show()
          Makes the ChatWindow visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatWindow

public ChatWindow(int x,
                  int y,
                  java.lang.String title)
Constructs a ChatWindow at a given position on the screen and with a given title which is displayed in the title bar of the window. Note that the window is initially invisible. You must call the show method in order to display the window.

Note: Depending on which window manager/window system you use, both window title and position might be ignored.

Parameters:
x - the x coordinate of the position of the window
y - the y coordinate of the position of the window
title - a String containing the title to be displayed in the title bar of the window
Method Detail

add

public void add(java.lang.String message)
Adds a new message to the message area in the upper part of the ChatWindow. The new message should consist of a String containing a single line of text. The new message is added to the bottom of the message area.

Parameters:
message - a String containing the message to add

clear

public void clear()
Clears the contents of the message area in the upper part of the ChatWindow.


hide

public void hide()
Makes the ChatWindow invisible. Call show to make the window visible again.

See Also:
show()

show

public void show()
Makes the ChatWindow visible. ChatWindows is initially invisible when having been created. To actually make it visible you must call the show method. Call hide to make the window invisible again.

See Also:
hide()

destroy

public void destroy()
Destroys the ChatWindow and frees all resources associated with it. The destroy method should be called when the ChatWindow is not needed anymore. Note that it is ILLEGAL to call any method of the ChatWindow object once destroy has been called.


messageEntered

public void messageEntered(java.lang.String message)
The messageEntered method is called whenever the user submits a new message and controls how to handle the new message. The intention is that this method should be overloaded in a subclass to ChatWindow. The default implementation found in the ChatWindow class does nothing.

Parameters:
message - a String containing the new message entered by the user