home *** CD-ROM | disk | FTP | other *** search
/ Datatid 2000 #1 / Datatid-2000-01.iso / Internet / SPLASH / SPLASH12.EXE / data1.cab / Plugins / _Menu / Pop_Menu / PopMenu.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-12-18  |  3.7 KB  |  119 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.Graphics;
  7. import java.awt.Image;
  8. import java.net.MalformedURLException;
  9. import java.net.URL;
  10.  
  11. public class PopMenu extends Applet {
  12.    private static final int BUTTON_LIMIT = 20;
  13.    private String qFileName;
  14.    private String[] URLName = new String[20];
  15.    private String[] caption = new String[20];
  16.    private Image[] buttonImage = new Image[20];
  17.    private PopBtn[] button = new PopBtn[20];
  18.    private int[] labelPos = new int[20];
  19.    private int buttonCount;
  20.    private String frame;
  21.    private int defaultLabelPos;
  22.    private static final String PARAM_URL = "HREF";
  23.    private static final String PARAM_IMAGE = "SRC";
  24.    private static final String PARAM_TEXT = "TEXT";
  25.    private static final String PARAM_FRAME = "FRAME";
  26.    private static final String PARAM_LABEL_POS = "LABELPOS";
  27.  
  28.    public String[][] getParameterInfo() {
  29.       String[][] var1 = new String[][]{{"HREF", "String", "URL name - append number"}, {"SRC", "Image", "Image name - append number"}, {"TEXT", "String", "Text - append number"}, {"FRAME", "String", "Frame name - default _top"}, {"LABELPOS", "String", "Label position - default below"}};
  30.       return var1;
  31.    }
  32.  
  33.    public String getAppletInfo() {
  34.       return "Name: PopMenu\r\nAuthor: David Griffiths\r\nCreated with Sun JDK 1.1";
  35.    }
  36.  
  37.    public boolean mouseUp(Event var1, int var2, int var3) {
  38.       for(int var4 = 0; var4 < this.buttonCount; ++var4) {
  39.          if (this.button[var4].equals(var1.target)) {
  40.             ((Applet)this).getAppletContext().showStatus(this.URLName[var4]);
  41.  
  42.             try {
  43.                URL var5 = new URL(((Applet)this).getDocumentBase(), this.URLName[var4]);
  44.                ((Applet)this).getAppletContext().showDocument(var5, this.frame);
  45.             } catch (MalformedURLException var6) {
  46.                ((Applet)this).getAppletContext().showStatus("Bad URL: " + this.URLName[var4]);
  47.                return false;
  48.             }
  49.          }
  50.       }
  51.  
  52.       return true;
  53.    }
  54.  
  55.    private int setLabelPos(String var1, int var2) {
  56.       int var3;
  57.       if (var1 == null) {
  58.          var3 = var2;
  59.       } else if ("RIGHT".equals(var1.toUpperCase())) {
  60.          var3 = 0;
  61.       } else {
  62.          var3 = var2;
  63.       }
  64.  
  65.       return var3;
  66.    }
  67.  
  68.    private void initGUI() {
  69.       for(int var1 = 0; var1 < this.buttonCount; ++var1) {
  70.          ((Container)this).add(this.button[var1] = new PopBtn(this.caption[var1], this.buttonImage[var1], this.labelPos[var1]));
  71.       }
  72.  
  73.    }
  74.  
  75.    public void init() {
  76.       String var1 = "a";
  77.       int var2 = 0;
  78.       int var3 = 0;
  79.       var1 = ((Applet)this).getParameter("FRAME");
  80.       if (var1 != null) {
  81.          this.frame = var1;
  82.       } else {
  83.          this.frame = "_top";
  84.       }
  85.  
  86.       var1 = ((Applet)this).getParameter("LABELPOS");
  87.  
  88.       for(this.defaultLabelPos = this.setLabelPos(var1, 1); var2 < 20 && var3 < 40; ++var3) {
  89.          var1 = ((Applet)this).getParameter("HREF" + var3);
  90.          if (var1 != null) {
  91.             this.URLName[var2] = var1;
  92.             var1 = ((Applet)this).getParameter("TEXT" + var3);
  93.             if (var1 != null) {
  94.                this.caption[var2] = var1;
  95.             }
  96.  
  97.             var1 = ((Applet)this).getParameter("SRC" + var3);
  98.             if (var1 != null) {
  99.                this.buttonImage[var2] = ((Applet)this).getImage(((Applet)this).getDocumentBase(), var1);
  100.             }
  101.  
  102.             var1 = ((Applet)this).getParameter("LABELPOS" + var3);
  103.             this.labelPos[var2] = this.setLabelPos(var1, this.defaultLabelPos);
  104.             ++var2;
  105.          }
  106.       }
  107.  
  108.       this.buttonCount = var2;
  109.       this.initGUI();
  110.    }
  111.  
  112.    public void paint(Graphics var1) {
  113.       var1.setColor(Color.white);
  114.       var1.drawRect(1, 1, ((Component)this).size().width - 2, ((Component)this).size().height - 2);
  115.       var1.setColor(Color.gray);
  116.       var1.drawRect(0, 0, ((Component)this).size().width - 2, ((Component)this).size().height - 2);
  117.    }
  118. }
  119.