gui
Class ChatBox

java.lang.Object
  extended bycore.EventNotifier
      extended bygui.ChatBox
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.KeyListener, java.awt.event.WindowListener

public class ChatBox
extends EventNotifier
implements java.awt.event.KeyListener, java.awt.event.ActionListener, java.awt.event.WindowListener

This is the window where text from contacts will be displayed. It is also where the user will enter text to be sent to that specific contact.

Author:
holschuj, schmitth, cooperse, hoele

Constructor Summary
ChatBox(Contact me, Contact you, java.awt.Point location, Prefs prefs, java.security.PrivateKey myKey)
          Main constructor
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 javax.swing.JPopupMenu createPopupMenu()
          Creates the popup menu with two entries, Save and Clear.
 void display()
          Create the GUI and show it.
 void displayBuddyText(java.lang.String text)
          Displays the name, time and text to the message window.
 void displaySendText(java.lang.String text)
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void notifyUser()
          Makes the toolbar icon blink if the window doesn't have focus This only works in windows
 void saveConv()
          Saves the conversation.
 void windowActivated(java.awt.event.WindowEvent e)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent e)
           
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class core.EventNotifier
addListener, removeListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatBox

public ChatBox(Contact me,
               Contact you,
               java.awt.Point location,
               Prefs prefs,
               java.security.PrivateKey myKey)
Main constructor

Parameters:
me - A contact object that is the user
you - A contact object that is the person we are talking to
location - Where on screen the box should be displayed
prefs - The Prefs object from MessengerApp
Method Detail

createPopupMenu

public javax.swing.JPopupMenu createPopupMenu()
Creates the popup menu with two entries, Save and Clear.


notifyUser

public void notifyUser()
Makes the toolbar icon blink if the window doesn't have focus This only works in windows


saveConv

public void saveConv()
Saves the conversation. Creates a fileChooser so the user can browse to the file or location where they want to save.


keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Specified by:
windowOpened in interface java.awt.event.WindowListener

displayBuddyText

public void displayBuddyText(java.lang.String text)
Displays the name, time and text to the message window.

Parameters:
text - The text that is to be displayed in the message window

displaySendText

public void displaySendText(java.lang.String text)
Parameters:
text - takes in a string of text and displays it in itself.

display

public void display()
Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread.