home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.3 KB | 53 lines |
- // SuperPanels.java
- // 27.02.96
- //
- // a group of SuperPanel objects with some handy methods
-
- package cybcerone.utils;
-
- import java.awt.Panel;
- import java.awt.CardLayout;
- import java.awt.Rectangle;
- import java.util.Hashtable;
- import java.util.Enumeration;
-
- /**
- * A group of SuperPanels, all in the same Panel. This is used by
- * the mother applet to switch between SuperPanel objects.
- */
- public class SuperPanels extends Panel {
- private static final Rectangle placement = Scaler.scale (0, 0, 1024, 668);
-
- private static Hashtable panels;
- private static CardLayout theLayout;
-
- public SuperPanels () {
- reshape (placement.x, placement.y, placement.width, placement.height);
-
- panels = new Hashtable ();
- setLayout (theLayout = new CardLayout ());
- }
-
- public void add (SuperPanel newPanel) {
- String id = newPanel.getId ();
-
- add (id, newPanel);
- panels.put (id, newPanel);
- }
-
- public SuperPanel switchTo (String newPanelId) {
- ((CardLayout)getLayout()).show (this, newPanelId);
- return ((SuperPanel)panels.get (newPanelId));
- }
-
- public Enumeration elements () {
- return panels.elements ();
- }
-
- public void reset () {
- for (Enumeration e = panels.elements ();
- e.hasMoreElements ();)
- ((SuperPanel)e.nextElement()).reset ();
- }
- }
-