home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 12,000 to 12,999 / 12000.zip / AOLDLs / Online-Tools / Java-Applets / JAVAAPPS.lzh / JAVAAPPS / WHO / WHO.EXE / WhoYouAre.java < prev   
Encoding:
Java Source  |  1996-07-16  |  4.1 KB  |  142 lines

  1. /* WhoYouAre => An applet that confuses people who are of the
  2.  
  3.  * opinion that they have just been fingered.
  4.  
  5.  * Written by Michael Schmidt in the night of May 10, 1996.
  6.  
  7.  * This is just a rough code. When I'm back from Paris next
  8.  
  9.  * week (Disneyland), I'll send the code with improved
  10.  
  11.  * color routines.
  12.  
  13.  * I hope that you understand the parameters!
  14.  
  15.  * Bye and have fun!
  16.  
  17.  * Michael
  18.  
  19.  *
  20.  
  21.  * <m.schmidt@ndh.com>
  22.  
  23.  */
  24.  
  25.  
  26.  
  27. import java.applet.Applet;
  28.  
  29. import java.awt.*;
  30.  
  31. import java.net.InetAddress;
  32.  
  33. import java.net.UnknownHostException;
  34.  
  35.  
  36.  
  37. public class WhoYouAre extends java.applet.Applet
  38.  
  39. {
  40.  
  41.     InetAddress YourAd= null;                             
  42.  
  43.         public void paint(Graphics g)
  44.  
  45.    {
  46.  
  47.      int f_Size;
  48.  
  49.     String f_SiStr = getParameter("f_Size");
  50.  
  51.         if (f_SiStr == null)
  52.  
  53.             f_Size = 20;
  54.  
  55.         else f_Size = Integer.parseInt(f_SiStr);
  56.  
  57.     
  58.  
  59.     int f_Type;
  60.  
  61.     String f_TyStr = getParameter("f_Type");
  62.  
  63.         if (f_TyStr == null)
  64.  
  65.             f_Type = Font.PLAIN;
  66.  
  67.         else if (f_TyStr.equalsIgnoreCase("BOLD"))
  68.  
  69.             f_Type = Font.BOLD;
  70.  
  71.         else if (f_TyStr.equalsIgnoreCase("ITALIC"))
  72.  
  73.             f_Type = Font.ITALIC;
  74.  
  75.         else 
  76.  
  77.             f_Type = Font.PLAIN;
  78.  
  79.  
  80.  
  81.     String f_Name;
  82.  
  83.     f_Name = getParameter("f_Name");
  84.  
  85.         if (f_Name == null)
  86.  
  87.             f_Name = "TimesRoman";
  88.  
  89.  
  90.  
  91.     Font f = new Font(f_Name,f_Type,f_Size);        
  92.  
  93.  
  94.  
  95.     FontMetrics fm = getFontMetrics(f);
  96.  
  97.     g.setFont(f);
  98.  
  99.      
  100.  
  101.      Color f_Colo;
  102.  
  103.           String f_CoStr = getParameter("f_Colo");
  104.  
  105.         if (f_CoStr == null)
  106.  
  107.             f_Colo = Color.white;
  108.  
  109.         else if (f_CoStr.equalsIgnoreCase("black"))
  110.  
  111.             f_Colo = Color.black;        
  112.  
  113.         else if (f_CoStr.equalsIgnoreCase("blue"))
  114.  
  115.             f_Colo = Color.blue;
  116.  
  117.         else if (f_CoStr.equalsIgnoreCase("darkGray"))
  118.  
  119.             f_Colo = Color.darkGray;
  120.  
  121.         else if (f_CoStr.equalsIgnoreCase("gray"))
  122.  
  123.             f_Colo = Color.gray;
  124.  
  125.         else if (f_CoStr.equalsIgnoreCase("lightGray"))
  126.  
  127.             f_Colo = Color.lightGray;
  128.  
  129.         else if (f_CoStr.equalsIgnoreCase("cyan"))
  130.  
  131.             f_Colo = Color.cyan;
  132.  
  133.         else if (f_CoStr.equalsIgnoreCase("orange"))
  134.  
  135.             f_Colo = Color.orange;
  136.  
  137.         else if (f_CoStr.equalsIgnoreCase("pink"))
  138.  
  139.             f_Colo = Color.pink;
  140.  
  141.         else if (f_CoStr.equalsIgnoreCase("red"))
  142.  
  143.             f_Colo = Color.red;
  144.  
  145.         else if (f_CoStr.equalsIgnoreCase("yellow"))
  146.  
  147.             f_Colo = Color.yellow;
  148.  
  149.         else if (f_CoStr.equalsIgnoreCase("magenta"))
  150.  
  151.             f_Colo = Color.magenta;
  152.  
  153.         else if (f_CoStr.equalsIgnoreCase("green"))
  154.  
  155.             f_Colo = Color.green;
  156.  
  157.         else 
  158.  
  159.             f_Colo = Color.white;
  160.  
  161.  
  162.  
  163.     Color bg_Col;
  164.  
  165.           String bg_ColStr = getParameter("bg_Col");
  166.  
  167.         if (bg_ColStr == null)
  168.  
  169.             bg_Col = Color.white;
  170.  
  171.         else if (bg_ColStr.equalsIgnoreCase("black"))
  172.  
  173.             bg_Col = Color.black;        
  174.  
  175.         else if (bg_ColStr.equalsIgnoreCase("blue"))
  176.  
  177.             bg_Col = Color.blue;
  178.  
  179.         else if (bg_ColStr.equalsIgnoreCase("darkGray"))
  180.  
  181.             bg_Col = Color.darkGray;
  182.  
  183.         else if (bg_ColStr.equalsIgnoreCase("gray"))
  184.  
  185.             bg_Col = Color.gray;
  186.  
  187.         else if (bg_ColStr.equalsIgnoreCase("lightGray"))
  188.  
  189.             bg_Col = Color.lightGray;
  190.  
  191.         else if (bg_ColStr.equalsIgnoreCase("cyan"))
  192.  
  193.             bg_Col = Color.cyan;
  194.  
  195.         else if (bg_ColStr.equalsIgnoreCase("orange"))
  196.  
  197.             bg_Col = Color.orange;
  198.  
  199.         else if (bg_ColStr.equalsIgnoreCase("pink"))
  200.  
  201.             bg_Col = Color.pink;
  202.  
  203.         else if (bg_ColStr.equalsIgnoreCase("red"))
  204.  
  205.             bg_Col = Color.red;
  206.  
  207.         else if (bg_ColStr.equalsIgnoreCase("yellow"))
  208.  
  209.             bg_Col = Color.yellow;
  210.  
  211.         else if (bg_ColStr.equalsIgnoreCase("magenta"))
  212.  
  213.             bg_Col = Color.magenta;
  214.  
  215.         else if (bg_ColStr.equalsIgnoreCase("green"))
  216.  
  217.             bg_Col = Color.green;
  218.  
  219.         else 
  220.  
  221.             bg_Col = Color.white;
  222.  
  223.  
  224.  
  225.  
  226.  
  227.         try{
  228.  
  229.                 YourAd = InetAddress.getLocalHost();                    
  230.  
  231.         }
  232.  
  233.         catch(UnknownHostException nohost){}
  234.  
  235.         
  236.  
  237.     String hello = "Guten Tag ",
  238.  
  239.           WhoYouR = YourAd.getHostName(),
  240.  
  241.           in_Str = getParameter("in_Str"),
  242.  
  243.           ou_Str = getParameter("ou_Str"),
  244.  
  245.           message = in_Str+WhoYouR+ou_Str;
  246.  
  247.      
  248.  
  249.      String xStr = getParameter("x_Text");
  250.  
  251.          int x = Integer.parseInt(xStr);
  252.  
  253.     String yStr = getParameter("y_Text");
  254.  
  255.          int y = Integer.parseInt(yStr);         
  256.  
  257.     
  258.  
  259.         int xs = fm.stringWidth(message)+x;
  260.  
  261.         int ys = fm.getHeight();
  262.  
  263.     
  264.  
  265.     g.setColor(bg_Col);
  266.  
  267.     g.fillRect(0,0,xs+x,ys+5);       
  268.  
  269.           
  270.  
  271.     g.setColor(f_Colo);
  272.  
  273.       g.drawString(message, x, y);
  274.  
  275.  
  276.  
  277.     }
  278.  
  279. }
  280.  
  281.  
  282.  
  283.