home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-03-13 | 1.4 KB | 63 lines |
- import java.awt.*;
- import java.applet.*;
-
- public class ConfigApplet4 extends Applet
- {
- String str;
- Point position;
-
- public void init()
- {
- HandleTextParam();
- HandleTypeSizeParam();
- HandlePositionParam();
- }
-
- public void paint(Graphics g)
- {
- g.drawString(str, position.x, position.y);
- }
-
- protected void HandleTextParam()
- {
- str = getParameter("text");
- if (str == null)
- str = "Default Text";
- }
-
- protected void HandleTypeSizeParam()
- {
- String s = getParameter("typesize");
- if (s == null)
- s = "24";
- int typeSize = Integer.parseInt(s);
- if ((typeSize < 10) || (typeSize > 72))
- typeSize = 24;
-
- Font font = new Font("TimesRoman", Font.BOLD, typeSize);
- setFont(font);
- }
-
- protected void HandlePositionParam()
- {
- String s = getParameter("xpos");
- if (s == null)
- s = "20";
- int xpos = Integer.parseInt(s);
-
- s = getParameter("ypos");
- if (s == null)
- s = "50";
- int ypos = Integer.parseInt(s);
-
- Dimension size = size();
- if ((xpos < 0) || (xpos > size.width))
- xpos = size.width / 2;
- if ((ypos < 0) || (ypos > size.height))
- ypos = size.height / 2;
-
- position = new Point(xpos, ypos);
- }
- }
-
-