| netscape.samples.showtext.ShowText.java |
netscape.samples.showtext.ShowText.java |
* Do not be alarmed: this is intentional and should * not impact the usability of the JavaDocs as a reference. */ public class ShowText extends java.applet.Applet { /** * The string which stores the message * to be displayed by the Applet/Bean */ public String message = null; /** * Initializes the Applet / Bean with properties * from PARAM tags to support HTML Serialization * model -- thus getting the initial values from * HTML instead of from a .ser * file. */ public void init() { // gets message from "message" param in HTML // for HTML-serialization support String textVal = getParameter("message"); // set the message setMessage(textVal); // set the font setFont(new Font("TimesRoman",Font.ITALIC | Font.BOLD,36)); } /** * Paints the message string with a dark-gray drop shadow * @see setMessage */ public void paint(Graphics g) { g.setColor(Color.gray); g.drawString(message,20, 45); g.setColor(Color.black); g.drawString(message,17, 37); } /** * getMessage is the "getter" method * for the message property */ public String getMessage() { return message; } /** * setMessage is the setter method * for the message property -- defaults * to "Netscape" if null is passed. *
* Sets message and forces a repaint. */ public void setMessage(String newVal) { message = newVal; if (message == null) { message = "Netscape"; } repaint(); } }