home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / enxle1f6 / src / games / battle / client / europaclient / queuecomponent.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  2.3 KB  |  108 lines

  1. /*
  2.  * @(#)QueueComponent.java
  3.  */
  4.  
  5. package games.Battle.client.EuropaClient;
  6.  
  7. import java.awt.*;
  8.  
  9. import games.Battle.shared.comm.*;
  10.  
  11. /**
  12.  * QueueComponent is a base class allowing various implementations
  13.  * of graphics to display the waiting queue's for games on the
  14.  * Europa server.
  15.  */
  16. public abstract class QueueComponent extends Panel {
  17.  
  18.     /** 
  19.      * The GameInfo instance for this queue.
  20.      */
  21.     GameInfo game;
  22.  
  23.     /**
  24.      * The client applet.
  25.      */
  26.     EuropaClient client;
  27.  
  28.     /**
  29.      * Construct a QueueComponent.
  30.      */
  31.     QueueComponent(GameInfo game, EuropaClient client) {
  32.         this.game = game;
  33.         this.client = client;
  34.     }
  35.  
  36.     /**
  37.      * The method to hilite a queue component, when the mouse moves
  38.      * into the window. This method is implemented in subclasses
  39.      * to provided behaviour.
  40.      */
  41.     public abstract void hilite();
  42.  
  43.     /**
  44.      * The method to normalize or unhilite a queue component, when the
  45.      * mouse moves out of the window. This method is implemented in
  46.      * subclasses to provide behaviour.
  47.      */
  48.     public abstract void normal();
  49.  
  50.     /**
  51.      * Notifies the QueueComponent that the information associated with
  52.      * a particular game has changed and needs to be updated. A repaint
  53.      * is automatically called so that the component will update itself.
  54.      */
  55.     public void resetGameInfo(GameInfo g) {
  56.         game = g;
  57.         repaint();
  58.     }
  59.  
  60.     /**
  61.      * Process the event that occurs when the mouse enters the 
  62.      * component. Calls hilite().
  63.      * @param e the event
  64.      * @param x the x location
  65.      * @param y the y location
  66.      * @see #hilite
  67.      */
  68.     public boolean mouseEnter(Event e, int x, int y) {
  69.         super.mouseEnter(e, x, y);
  70.         hilite();
  71.         return true;
  72.     }
  73.  
  74.     /**
  75.      * Process the event that occurs when the mouse exits the 
  76.      * component. Calls normal().
  77.      * @param e the event
  78.      * @param x the x location
  79.      * @param y the y location
  80.      * @see #normal
  81.      */
  82.     public boolean mouseExit(Event e, int x, int y) {
  83.         super.mouseExit(e, x, y);
  84.         normal();
  85.         return true;
  86.     }
  87.  
  88.     /**
  89.      * Process a mouse up event. Tries to join a particular game
  90.      * queue.
  91.      * @param e the event
  92.      * @param x the x location
  93.      * @param y the y location
  94.      */
  95.     public boolean mouseUp(Event e, int x, int y) {
  96.         super.mouseUp(e, x, y);
  97.         normal();
  98.         try {
  99.             client.join(game.getId());
  100.         }
  101.         catch (Exception err) {
  102.             System.out.println("Exception: "+err);
  103.         }
  104.         hilite();
  105.         return true;
  106.     }
  107. }
  108.