home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class PopMenu extends Applet {
- private static final int BUTTON_LIMIT = 20;
- private String qFileName;
- private String[] URLName = new String[20];
- private String[] caption = new String[20];
- private Image[] buttonImage = new Image[20];
- private PopBtn[] button = new PopBtn[20];
- private int[] labelPos = new int[20];
- private int buttonCount;
- private String frame;
- private int defaultLabelPos;
- private static final String PARAM_URL = "HREF";
- private static final String PARAM_IMAGE = "SRC";
- private static final String PARAM_TEXT = "TEXT";
- private static final String PARAM_FRAME = "FRAME";
- private static final String PARAM_LABEL_POS = "LABELPOS";
-
- public String[][] getParameterInfo() {
- 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"}};
- return var1;
- }
-
- public String getAppletInfo() {
- return "Name: PopMenu\r\nAuthor: David Griffiths\r\nCreated with Sun JDK 1.1";
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- for(int var4 = 0; var4 < this.buttonCount; ++var4) {
- if (this.button[var4].equals(var1.target)) {
- ((Applet)this).getAppletContext().showStatus(this.URLName[var4]);
-
- try {
- URL var5 = new URL(((Applet)this).getDocumentBase(), this.URLName[var4]);
- ((Applet)this).getAppletContext().showDocument(var5, this.frame);
- } catch (MalformedURLException var6) {
- ((Applet)this).getAppletContext().showStatus("Bad URL: " + this.URLName[var4]);
- return false;
- }
- }
- }
-
- return true;
- }
-
- private int setLabelPos(String var1, int var2) {
- int var3;
- if (var1 == null) {
- var3 = var2;
- } else if ("RIGHT".equals(var1.toUpperCase())) {
- var3 = 0;
- } else {
- var3 = var2;
- }
-
- return var3;
- }
-
- private void initGUI() {
- for(int var1 = 0; var1 < this.buttonCount; ++var1) {
- ((Container)this).add(this.button[var1] = new PopBtn(this.caption[var1], this.buttonImage[var1], this.labelPos[var1]));
- }
-
- }
-
- public void init() {
- String var1 = "a";
- int var2 = 0;
- int var3 = 0;
- var1 = ((Applet)this).getParameter("FRAME");
- if (var1 != null) {
- this.frame = var1;
- } else {
- this.frame = "_top";
- }
-
- var1 = ((Applet)this).getParameter("LABELPOS");
-
- for(this.defaultLabelPos = this.setLabelPos(var1, 1); var2 < 20 && var3 < 40; ++var3) {
- var1 = ((Applet)this).getParameter("HREF" + var3);
- if (var1 != null) {
- this.URLName[var2] = var1;
- var1 = ((Applet)this).getParameter("TEXT" + var3);
- if (var1 != null) {
- this.caption[var2] = var1;
- }
-
- var1 = ((Applet)this).getParameter("SRC" + var3);
- if (var1 != null) {
- this.buttonImage[var2] = ((Applet)this).getImage(((Applet)this).getDocumentBase(), var1);
- }
-
- var1 = ((Applet)this).getParameter("LABELPOS" + var3);
- this.labelPos[var2] = this.setLabelPos(var1, this.defaultLabelPos);
- ++var2;
- }
- }
-
- this.buttonCount = var2;
- this.initGUI();
- }
-
- public void paint(Graphics var1) {
- var1.setColor(Color.white);
- var1.drawRect(1, 1, ((Component)this).size().width - 2, ((Component)this).size().height - 2);
- var1.setColor(Color.gray);
- var1.drawRect(0, 0, ((Component)this).size().width - 2, ((Component)this).size().height - 2);
- }
- }
-