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

  1. /*
  2.  * (#)@QueuePanel.java
  3.  */
  4. package games.Battle.client.EuropaClient;
  5.  
  6. import java.awt.*;
  7. import java.util.*;
  8.  
  9. import games.Battle.shared.comm.*;
  10.  
  11. /**
  12.  * QueuePanel implements the panel of controls that the user sees for 
  13.  * choosing a game queue. The user picks a game queue, and when the
  14.  * queue fills up the game starts.
  15.  */
  16.  
  17. class QueuePanel extends Panel {
  18.     /**
  19.      * A table of all known game queue components
  20.      */
  21.     Dictionary queueTable;
  22.     /**
  23.      * A reference back to the actual game client
  24.      */
  25.     EuropaClient client;
  26.  
  27.     /**
  28.      * construct the grid of the Queue panel.
  29.      * @param numGames how many games will appear, 
  30.      *                 expected to be a multiple of 4
  31.      */
  32.     public QueuePanel(int numGames, EuropaClient client) {
  33.         setBackground(Color.orange);
  34.         int rows = numGames / 4;
  35.         setLayout(new GridLayout(rows, 4, 2, 2));
  36.         queueTable = new Hashtable();
  37.         this.client = client;
  38.     }
  39.  
  40.     public void setGameInfo(GameInfo game) {
  41.         QueueComponent q = (QueueComponent)queueTable.get(game);
  42.  
  43.         if (q == null) {
  44.             q = new EuropaQueueComponent(game, client);
  45.             queueTable.put(game, q);
  46.             add(q);
  47.         }
  48.         else {
  49.             q.resetGameInfo(game);
  50.         }
  51.     }
  52. }
  53.