home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Point;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class CoolBtn extends Applet implements Runnable {
- Thread m_CoolBtn;
- private Image m_imgMouseIn;
- private Image m_imgMouseOut;
- private Image m_imgMouseDown;
- private int m_bBackR;
- private int m_bBackG;
- private int m_bBackB;
- private Font m_fontFace;
- private Point m_ptImg;
- private Point m_ptFaceText;
- private boolean m_bMouseIn;
- private boolean m_bMouseDown;
- private String m_FaceText = "";
- private URL m_URL;
- private String m_strTarget = "";
- private int m_nBackR;
- private int m_nBackG;
- private int m_nBackB;
- private final String PARAM_FaceText = "FaceText";
- private final String PARAM_URL = "URL";
- private final String PARAM_TARGET = "Target";
- private final String PARAM_BACKR = "R";
- private final String PARAM_BACKG = "G";
- private final String PARAM_BACKB = "B";
-
- public String getAppletInfo() {
- return "Name: CoolBtn\r\nAuthor: Yuheng Zhao & Dazhi Liu";
- }
-
- public String[][] getParameterInfo() {
- String[][] var1 = new String[][]{{"FaceText", "String", "Face Text"}, {"URL", "String", "URL"}, {"Target", "Target", "Target"}};
- return var1;
- }
-
- public void init() {
- String var1 = ((Applet)this).getParameter("FaceText");
- this.m_FaceText = var1;
- var1 = ((Applet)this).getParameter("Target");
- this.m_strTarget = var1;
- var1 = ((Applet)this).getParameter("R");
- this.m_nBackR = Integer.parseInt(var1);
- var1 = ((Applet)this).getParameter("G");
- this.m_nBackG = Integer.parseInt(var1);
- var1 = ((Applet)this).getParameter("B");
- this.m_nBackB = Integer.parseInt(var1);
-
- try {
- var1 = ((Applet)this).getParameter("URL");
- if (var1 != null) {
- this.m_URL = new URL(((Applet)this).getDocumentBase(), var1);
- }
- } catch (MalformedURLException var3) {
- }
-
- this.m_imgMouseIn = ((Applet)this).getImage(((Applet)this).getDocumentBase(), "images/mouseIn.gif");
- this.m_imgMouseOut = ((Applet)this).getImage(((Applet)this).getDocumentBase(), "images/mouseOut.gif");
- this.m_imgMouseDown = ((Applet)this).getImage(((Applet)this).getDocumentBase(), "images/mouseDown.gif");
- this.m_fontFace = new Font("Arial", 1, 14);
- this.m_bMouseIn = false;
- this.m_bMouseDown = false;
- ((Component)this).setBackground(new Color(this.m_nBackR, this.m_nBackG, this.m_nBackB));
- Dimension var2 = ((Component)this).size();
- this.m_ptImg = new Point(10, (var2.height - 10) / 2);
- this.m_ptFaceText = new Point(26, var2.height / 2 + 5);
- }
-
- public void destroy() {
- }
-
- public void paint(Graphics var1) {
- if (this.m_bMouseIn) {
- if (this.m_bMouseDown) {
- var1.drawImage(this.m_imgMouseDown, this.m_ptImg.x, this.m_ptImg.y, this);
- var1.setColor(new Color(128, 0, 0));
- } else {
- var1.drawImage(this.m_imgMouseIn, this.m_ptImg.x, this.m_ptImg.y, this);
- var1.setColor(new Color(255, 0, 0));
- }
- } else {
- var1.drawImage(this.m_imgMouseOut, this.m_ptImg.x, this.m_ptImg.y, this);
- var1.setColor(new Color(0, 0, 0));
- }
-
- var1.setFont(this.m_fontFace);
- var1.drawString(this.m_FaceText, this.m_ptFaceText.x, this.m_ptFaceText.y);
- }
-
- public void start() {
- if (this.m_CoolBtn == null) {
- this.m_CoolBtn = new Thread(this);
- this.m_CoolBtn.start();
- }
-
- }
-
- public void stop() {
- if (this.m_CoolBtn != null) {
- this.m_CoolBtn.stop();
- this.m_CoolBtn = null;
- }
-
- }
-
- public void run() {
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- this.m_bMouseIn = true;
- this.m_bMouseDown = true;
- ((Component)this).repaint();
- return true;
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- this.m_bMouseIn = true;
- this.m_bMouseDown = false;
- ((Component)this).repaint();
- if (this.m_URL != null) {
- if (this.m_strTarget != null) {
- ((Applet)this).getAppletContext().showDocument(this.m_URL, this.m_strTarget);
- } else {
- ((Applet)this).getAppletContext().showDocument(this.m_URL, "_self");
- }
- }
-
- return true;
- }
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- this.m_bMouseIn = true;
- this.m_bMouseDown = false;
- ((Component)this).repaint();
- ((Applet)this).showStatus(this.m_URL.toString());
- return true;
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- this.m_bMouseIn = false;
- this.m_bMouseDown = false;
- ((Component)this).repaint();
- return true;
- }
- }
-