home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-07-16 | 4.1 KB | 142 lines |
- /* WhoYouAre => An applet that confuses people who are of the
-
- * opinion that they have just been fingered.
-
- * Written by Michael Schmidt in the night of May 10, 1996.
-
- * This is just a rough code. When I'm back from Paris next
-
- * week (Disneyland), I'll send the code with improved
-
- * color routines.
-
- * I hope that you understand the parameters!
-
- * Bye and have fun!
-
- * Michael
-
- *
-
- * <m.schmidt@ndh.com>
-
- */
-
-
-
- import java.applet.Applet;
-
- import java.awt.*;
-
- import java.net.InetAddress;
-
- import java.net.UnknownHostException;
-
-
-
- public class WhoYouAre extends java.applet.Applet
-
- {
-
- InetAddress YourAd= null;
-
- public void paint(Graphics g)
-
- {
-
- int f_Size;
-
- String f_SiStr = getParameter("f_Size");
-
- if (f_SiStr == null)
-
- f_Size = 20;
-
- else f_Size = Integer.parseInt(f_SiStr);
-
-
-
- int f_Type;
-
- String f_TyStr = getParameter("f_Type");
-
- if (f_TyStr == null)
-
- f_Type = Font.PLAIN;
-
- else if (f_TyStr.equalsIgnoreCase("BOLD"))
-
- f_Type = Font.BOLD;
-
- else if (f_TyStr.equalsIgnoreCase("ITALIC"))
-
- f_Type = Font.ITALIC;
-
- else
-
- f_Type = Font.PLAIN;
-
-
-
- String f_Name;
-
- f_Name = getParameter("f_Name");
-
- if (f_Name == null)
-
- f_Name = "TimesRoman";
-
-
-
- Font f = new Font(f_Name,f_Type,f_Size);
-
-
-
- FontMetrics fm = getFontMetrics(f);
-
- g.setFont(f);
-
-
-
- Color f_Colo;
-
- String f_CoStr = getParameter("f_Colo");
-
- if (f_CoStr == null)
-
- f_Colo = Color.white;
-
- else if (f_CoStr.equalsIgnoreCase("black"))
-
- f_Colo = Color.black;
-
- else if (f_CoStr.equalsIgnoreCase("blue"))
-
- f_Colo = Color.blue;
-
- else if (f_CoStr.equalsIgnoreCase("darkGray"))
-
- f_Colo = Color.darkGray;
-
- else if (f_CoStr.equalsIgnoreCase("gray"))
-
- f_Colo = Color.gray;
-
- else if (f_CoStr.equalsIgnoreCase("lightGray"))
-
- f_Colo = Color.lightGray;
-
- else if (f_CoStr.equalsIgnoreCase("cyan"))
-
- f_Colo = Color.cyan;
-
- else if (f_CoStr.equalsIgnoreCase("orange"))
-
- f_Colo = Color.orange;
-
- else if (f_CoStr.equalsIgnoreCase("pink"))
-
- f_Colo = Color.pink;
-
- else if (f_CoStr.equalsIgnoreCase("red"))
-
- f_Colo = Color.red;
-
- else if (f_CoStr.equalsIgnoreCase("yellow"))
-
- f_Colo = Color.yellow;
-
- else if (f_CoStr.equalsIgnoreCase("magenta"))
-
- f_Colo = Color.magenta;
-
- else if (f_CoStr.equalsIgnoreCase("green"))
-
- f_Colo = Color.green;
-
- else
-
- f_Colo = Color.white;
-
-
-
- Color bg_Col;
-
- String bg_ColStr = getParameter("bg_Col");
-
- if (bg_ColStr == null)
-
- bg_Col = Color.white;
-
- else if (bg_ColStr.equalsIgnoreCase("black"))
-
- bg_Col = Color.black;
-
- else if (bg_ColStr.equalsIgnoreCase("blue"))
-
- bg_Col = Color.blue;
-
- else if (bg_ColStr.equalsIgnoreCase("darkGray"))
-
- bg_Col = Color.darkGray;
-
- else if (bg_ColStr.equalsIgnoreCase("gray"))
-
- bg_Col = Color.gray;
-
- else if (bg_ColStr.equalsIgnoreCase("lightGray"))
-
- bg_Col = Color.lightGray;
-
- else if (bg_ColStr.equalsIgnoreCase("cyan"))
-
- bg_Col = Color.cyan;
-
- else if (bg_ColStr.equalsIgnoreCase("orange"))
-
- bg_Col = Color.orange;
-
- else if (bg_ColStr.equalsIgnoreCase("pink"))
-
- bg_Col = Color.pink;
-
- else if (bg_ColStr.equalsIgnoreCase("red"))
-
- bg_Col = Color.red;
-
- else if (bg_ColStr.equalsIgnoreCase("yellow"))
-
- bg_Col = Color.yellow;
-
- else if (bg_ColStr.equalsIgnoreCase("magenta"))
-
- bg_Col = Color.magenta;
-
- else if (bg_ColStr.equalsIgnoreCase("green"))
-
- bg_Col = Color.green;
-
- else
-
- bg_Col = Color.white;
-
-
-
-
-
- try{
-
- YourAd = InetAddress.getLocalHost();
-
- }
-
- catch(UnknownHostException nohost){}
-
-
-
- String hello = "Guten Tag ",
-
- WhoYouR = YourAd.getHostName(),
-
- in_Str = getParameter("in_Str"),
-
- ou_Str = getParameter("ou_Str"),
-
- message = in_Str+WhoYouR+ou_Str;
-
-
-
- String xStr = getParameter("x_Text");
-
- int x = Integer.parseInt(xStr);
-
- String yStr = getParameter("y_Text");
-
- int y = Integer.parseInt(yStr);
-
-
-
- int xs = fm.stringWidth(message)+x;
-
- int ys = fm.getHeight();
-
-
-
- g.setColor(bg_Col);
-
- g.fillRect(0,0,xs+x,ys+5);
-
-
-
- g.setColor(f_Colo);
-
- g.drawString(message, x, y);
-
-
-
- }
-
- }
-
-
-
-