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 / URL / URL.EXE / urname.java < prev   
Encoding:
Java Source  |  1996-03-09  |  787 b   |  29 lines

  1. // Used to get the user name. special crdits to Robert Scott at the 
  2.  
  3.  
  4. // Java message base for the tech part and Mig9 for the motivation part.
  5.  
  6.  
  7. // Amit C. (ConnectSoft Ruksun, Pune, India) amit@maverick.corus.co.in
  8.  
  9.  
  10.  
  11.  
  12.  
  13. import java.applet.Applet;
  14.  
  15.  
  16. import java.awt.Graphics;
  17.  
  18.  
  19. import java.net.InetAddress;
  20.  
  21.  
  22. import java.net.UnknownHostException;
  23.  
  24.  
  25.  
  26.  
  27.  
  28. public class urname extends Applet
  29.  
  30.  
  31. {
  32.  
  33.  
  34.     InetAddress myAddress= null;
  35.  
  36.  
  37.                                     
  38.  
  39.  
  40.     public void init()
  41.  
  42.  
  43.     {
  44.  
  45.  
  46.         try
  47.  
  48.  
  49.         {
  50.  
  51.  
  52.             myAddress = InetAddress.getLocalHost();
  53.  
  54.  
  55.         }
  56.  
  57.  
  58.         catch(UnknownHostException e){}
  59.  
  60.  
  61.     }
  62.  
  63.  
  64.     public void paint(Graphics g)
  65.  
  66.  
  67.     {
  68.  
  69.  
  70.         g.drawString("Welcome " + myAddress.getHostName() +"!", 10, 20);
  71.  
  72.  
  73. //        g.drawString(myAddress.toString(), 10, 20);    
  74.  
  75.  
  76.     }
  77.  
  78.  
  79.  
  80.  
  81.  
  82. }
  83.  
  84.  
  85.