home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / dek17tau / classes / spt / applet_drivers / imagebuttonappletdriver.java < prev   
Encoding:
Java Source  |  1996-08-14  |  1.0 KB  |  50 lines

  1.  
  2. package spt.applet_drivers;
  3.  
  4. import java.awt.*;
  5. import java.util.*;
  6. import java.applet.*;
  7.  
  8. import spt.applets.StdApplet;
  9. import spt.applets.ImageButtonApplet;
  10. import spt.gui.ImageButton;
  11.  
  12.  
  13. public class ImageButtonAppletDriver extends StdApplet {
  14.  
  15.     ImageButton button;
  16.     Checkbox en, dis;
  17.     String targetName;
  18.  
  19.     public void init() {
  20.         super.init();
  21.  
  22.         setLayout(new GridLayout(2, 1, 0, 0));
  23.  
  24.         CheckboxGroup g = new CheckboxGroup();
  25.         add(en = new Checkbox("Enabled", g, true));
  26.         add(dis = new Checkbox("Disabled", g, false));
  27.  
  28.         targetName = getParameter("TARGETAPP");
  29.     }
  30.  
  31.     public boolean handleEvent(Event e) {
  32.         if (button == null) {
  33.             Applet t=null;
  34.             if (targetName != null) t = getApplet(targetName);
  35.             if (t != null && t instanceof ImageButtonApplet) {
  36.                 button = ((ImageButtonApplet) t).getImageButton();
  37.             }
  38.         }
  39.  
  40.         if (button == null) return super.handleEvent(e);
  41.  
  42.         if (e.id == Event.ACTION_EVENT) {
  43.             if (e.target == en) button.enable();
  44.             else if (e.target == dis) button.disable();
  45.         }
  46.         return super.handleEvent(e);
  47.     }
  48. }
  49.  
  50.