home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / utils / superpanels.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.3 KB  |  53 lines

  1. // SuperPanels.java
  2. // 27.02.96
  3. //
  4. // a group of SuperPanel objects with some handy methods
  5.  
  6. package cybcerone.utils;
  7.  
  8. import java.awt.Panel;
  9. import java.awt.CardLayout;
  10. import java.awt.Rectangle;
  11. import java.util.Hashtable;
  12. import java.util.Enumeration;
  13.  
  14. /** 
  15.  * A group of SuperPanels, all in the same Panel.  This is used by
  16.  * the mother applet to switch between SuperPanel objects.
  17.  */
  18. public class SuperPanels extends Panel {
  19.   private static final Rectangle placement = Scaler.scale (0, 0, 1024, 668);
  20.  
  21.   private static Hashtable panels;
  22.   private static CardLayout theLayout;
  23.  
  24.   public SuperPanels () {
  25.     reshape (placement.x, placement.y, placement.width, placement.height);
  26.     
  27.     panels = new Hashtable ();
  28.     setLayout (theLayout = new CardLayout ());
  29.   }
  30.  
  31.   public void add (SuperPanel newPanel) {
  32.     String id = newPanel.getId ();
  33.  
  34.     add (id, newPanel);
  35.     panels.put (id, newPanel);
  36.   }
  37.  
  38.   public SuperPanel switchTo (String newPanelId) {
  39.     ((CardLayout)getLayout()).show (this, newPanelId);
  40.     return ((SuperPanel)panels.get (newPanelId));
  41.   }
  42.  
  43.   public Enumeration elements () {
  44.     return panels.elements ();
  45.   }
  46.  
  47.   public void reset () {
  48.     for (Enumeration e = panels.elements ();
  49.      e.hasMoreElements ();)
  50.       ((SuperPanel)e.nextElement()).reset ();
  51.   }
  52. }
  53.