home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / dek17tau / classes / spt / applets / dualimagebuttonapplet.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.7 KB  |  84 lines

  1.  
  2. /*
  3.  * DualImageButtonApplet.java
  4.  *
  5.  * Copyright (C) 1996 Shaun Terry. All Rights Reserved.
  6.  */
  7.  
  8. package spt.applets;
  9.  
  10. import java.awt.Image;
  11. import java.awt.Event;
  12. import java.net.URL;
  13. import java.net.MalformedURLException;
  14. import java.applet.*;
  15.  
  16. import spt.gui.ImagePanel;
  17. import spt.gui.AnimatedImageButton;
  18.  
  19.  
  20. /**
  21.  * A button applet that displays one image when at rest and another
  22.  * when the mouse is moved over it.<p>
  23.  * <strong>Parameters</strong>
  24.  * <pre>
  25.  * IMGONENTER    URL    The image to show when the mouse is over the button (required)
  26.  *
  27.  * </pre>
  28.  * Plus ImageButtonApplet and StdApplet parameters.
  29.  *
  30.  * @see spt.applets.StdApplet
  31.  * @see spt.applets.ImageButtonApplet
  32.  *
  33.  * @author Shaun Terry
  34.  */
  35.  
  36. public class DualImageButtonApplet extends ImageButtonApplet {
  37.  
  38.     AnimatedImageButton imgButton;
  39.  
  40.     public void init() {
  41.         stdAppletInit();
  42.  
  43.         URL img1=null, img2=null;
  44.         try {
  45.             img1 = paramParser.getURL("IMG");
  46.             img2 = paramParser.getURL("IMGONENTER");
  47.         }
  48.         catch (MalformedURLException e) {
  49.             System.err.println("Param(IMG1/2) Error: " + e);
  50.             return;
  51.         }
  52.  
  53.         String text = paramParser.getParameter("TEXT");
  54.  
  55.         imgButton = new AnimatedImageButton(text);
  56.  
  57.         Image ip;
  58.  
  59.         ip = ImagePanel.loadImage(this, img1);
  60.         imgButton.addImage(ip, 0);
  61.  
  62.         ip = ImagePanel.loadImage(this, img2);
  63.         imgButton.addImage(ip, Integer.MAX_VALUE);
  64.  
  65.         imgButton.setRepeat(true);
  66.         imgButton.setAnimateOnEnter(true);
  67.  
  68.         super.imgButton = imgButton;
  69.         super.setParams();
  70.  
  71.         imgButton.startAnimation();
  72.         add(imgButton);
  73.     }
  74.  
  75.     /** Parameters */
  76.     public String[][] getParameterInfo() {
  77.         String[][] info = {
  78.             { "IMGONENTER", "URL",     "The image when mouse enters" },
  79.         };
  80.  
  81.         return mergeParameters(super.getParameterInfo(), info);
  82.     }
  83. }
  84.