home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.applet.Applet; import java.awt.Component; import java.awt.Font; import java.awt.Graphics; public class StaticMarquee extends Applet { String m_string = ""; String m_font = "Courier"; String m_style = "PLAIN"; int m_size = 12; final String PARAM_string = "string"; final String PARAM_font = "font"; final String PARAM_style = "style"; final String PARAM_size = "size"; public void start() { } public String[][] getParameterInfo() { String[][] info = new String[][]{{"string", "String", "String to output in marquee"}, {"font", "String", "Font to use"}, {"style", "String", "PLAIN, BOLD, or ITALIC"}, {"size", "int", "Font size [pts]"}}; return info; } public void stop() { } public void finalize() { } public String getAppletInfo() { return "Name: StaticMarquee\r\n" + "Author: Stephen R. Davis\r\n" + "Created for Learn Java Now (c)"; } public void destroy() { } public void init() { String param = ((Applet)this).getParameter("string"); if (param != null) { this.m_string = param; } param = ((Applet)this).getParameter("font"); if (param != null) { this.m_font = param; } param = ((Applet)this).getParameter("style"); if (param != null) { this.m_style = param; } param = ((Applet)this).getParameter("size"); if (param != null) { this.m_size = Integer.parseInt(param); } int nStyle = 0; if (this.m_style.equalsIgnoreCase("BOLD")) { nStyle = 1; } if (this.m_style.equalsIgnoreCase("ITALIC")) { nStyle = 2; } Font font = new Font(this.m_font, nStyle, this.m_size); ((Component)this).setFont(font); } public void paint(Graphics g) { int nVertOffset = ((Component)this).size().height; nVertOffset = (nVertOffset - this.m_size) / 2; g.drawString(this.m_string, 5, nVertOffset + this.m_size); } }