home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.applet.Applet; import java.applet.AudioClip; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Event; import java.awt.Graphics; import java.awt.Image; import java.net.MalformedURLException; import java.net.URL; public class GraphicsButton extends Applet { Image buttonFace; AudioClip clip; boolean clicked = false; boolean enabled = true; // $FF: renamed from: x int final int field_0; // $FF: renamed from: y int final int field_1; protected final void drawCenteredImage(Graphics var1, int var2, int var3, int var4, int var5) { if (this.buttonFace != null) { int var6 = (var4 - this.buttonFace.getWidth(this)) / 2; int var7 = (var5 - this.buttonFace.getHeight(this)) / 2; var1.drawImage(this.buttonFace, var6 > 0 ? var6 + var2 : var2, var7 > 0 ? var7 + var3 : var3, this); } else { System.out.println("Cannot paint a picture: buttonFace == null"); } } protected void drawRaisedFrame(Graphics var1) { Dimension var2 = ((Component)this).size(); this.drawCenteredImage(var1, 1, 1, var2.width - 3, var2.height - 3); var1.setColor(Color.gray); var1.drawLine(var2.width - 2, 0, var2.width - 2, var2.height - 2); var1.drawLine(0, var2.height - 2, var2.width - 2, var2.height - 2); var1.setColor(Color.white); var1.drawLine(0, 0, 0, var2.height - 1); var1.drawLine(0, 0, var2.width - 1, 0); var1.setColor(Color.black); var1.drawLine(var2.width - 1, 0, var2.width - 1, var2.height - 2); var1.drawLine(0, var2.height - 1, var2.width - 1, var2.height - 1); } protected void drawIndentedFrame(Graphics var1) { Dimension var2 = ((Component)this).size(); this.drawCenteredImage(var1, 2, 2, var2.width - 3, var2.height - 3); var1.setColor(Color.gray); var1.drawLine(1, 0, 1, var2.height - 1); var1.drawLine(0, 1, var2.width, 1); var1.setColor(Color.black); var1.drawLine(0, 0, 0, var2.height); var1.drawLine(0, 0, var2.width, 0); var1.setColor(Color.white); var1.drawLine(var2.width - 1, 0, var2.width - 1, var2.height - 1); var1.drawLine(0, var2.height - 1, var2.width - 1, var2.height - 1); } public boolean mouseDown(Event var1, int var2, int var3) { if (this.enabled) { this.clicked = true; ((Component)this).repaint(); } return true; } // $FF: renamed from: go () void protected void method_0() { System.out.println("Loading: " + ((Applet)this).getParameter("href")); URL var1; try { var1 = new URL(((Applet)this).getDocumentBase(), ((Applet)this).getParameter("href")); } catch (MalformedURLException var2) { System.out.println("Bad URL:" + ((Applet)this).getParameter("href")); ((Applet)this).getAppletContext().showStatus("Cannot load this document"); return; } if (((Applet)this).getParameter("target") != null) { ((Applet)this).getAppletContext().showDocument(var1, ((Applet)this).getParameter("target")); } else { ((Applet)this).getAppletContext().showDocument(var1); } } public boolean mouseUp(Event var1, int var2, int var3) { if (this.enabled) { this.clicked = false; if (((Component)this).inside(var2, var3)) { this.method_0(); } ((Component)this).repaint(); } return true; } public String getAppletInfo() { return "GraphicsButton v 1.0.3 by Benoît Marchal <bmarchal@acm.com>\r\nCopyright © 1996, Benoît Marchal. All Rights Reserved.\nhttp://ourworld.compuserve.com/homepages/bmarchal/"; } public String[][] getParameterInfo() { String[][] var1 = new String[][]{{"src", "url", "image for button"}, {"href", "url", "url to retrieve on click"}, {"target", "string", "load URL into frame target"}, {"audiotip", "url", "sound when user flies over the button"}, {"tooltip", "string", "help for user (typically description of href)"}}; return var1; } public boolean mouseEnter(Event var1, int var2, int var3) { if (this.clip != null) { this.clip.play(); } return true; } public boolean mouseMove(Event var1, int var2, int var3) { ((Applet)this).getAppletContext().showStatus(((Applet)this).getParameter("Tooltip")); return true; } public void update(Graphics var1) { this.paint(var1); } public void init() { this.buttonFace = ((Applet)this).getImage(((Applet)this).getDocumentBase(), ((Applet)this).getParameter("src")); if (((Applet)this).getParameter("AudioTip") != null) { this.clip = ((Applet)this).getAudioClip(((Applet)this).getDocumentBase(), ((Applet)this).getParameter("AudioTip")); } else { this.clip = null; } this.enabled = ((Applet)this).getParameter("href") != null; } public void stop() { if (this.clip != null) { this.clip.stop(); } } public void destroy() { this.buttonFace = null; this.clip = null; } public void paint(Graphics var1) { Image var2 = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height); Graphics var3 = var2.getGraphics(); var3.setColor(Color.lightGray); var3.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height); if (this.clicked && this.enabled) { this.drawIndentedFrame(var3); } else { this.drawRaisedFrame(var3); } var1.drawImage(var2, 0, 0, this); Object var5 = null; Object var4 = null; } }