Guest User

Untitled

a guest
Mar 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.97 KB | None | 0 0
  1.     import java.applet.Applet;
  2.     import java.applet.AppletContext;
  3.     import java.awt.*;
  4.     import java.awt.event.ActionEvent;
  5.     import java.awt.event.ActionListener;
  6.     import java.io.*;
  7.     import java.net.MalformedURLException;
  8.     import java.net.URL;
  9.     import java.util.EventObject;
  10.      
  11.     public class PasswdLevel4 extends applet
  12.     implements actionlistener
  13.     {
  14.      
  15.     public PasswdLevel4()
  16.     {
  17.     inuser = new string[22];
  18.     totno = 0;
  19.     countConn = null;
  20.     countData = null;
  21.     inURL = null;
  22.     txtlogin = new textfield();
  23.     label1 = new label();
  24.     label2 = new label();
  25.     label3 = new label();
  26.     txtpass = new textfield();
  27.     lblstatus = new label();
  28.     ButOk = new button();
  29.     ButReset = new button();
  30.     lbltitle = new label();
  31.     }
  32.      
  33.     void ButOk_ActionPerformed(actionevent actionevent)
  34.     {
  35.     boolean flag = false;
  36.     for(int i = 1; i <= totno / 2; i++)
  37.     if(txtlogin.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 2].trim().toUpperCase().intern() && txtpass.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 3].trim().toUpperCase().intern())
  38.     {
  39.     lblstatus.setText("Login Success, Loading..");
  40.     flag = true;
  41.     string s = inuser[1].trim().intern();
  42.     string s1 = getParameter("targetframe");
  43.     if(s1 == null)
  44.     s1 = "_self";
  45.     try
  46.     {
  47.     finalurl = new url(getCodeBase(), s);
  48.     }
  49.     catch(malformedurlexception _ex)
  50.     {
  51.     lblstatus.setText("Bad URL");
  52.     }
  53.     getAppletContext().showDocument(finalurl, s1);
  54.     }
  55.      
  56.     if(!flag)
  57.     lblstatus.setText("Invaild Login or Password");
  58.     }
  59.      
  60.     void ButReset_ActionPerformed(actionevent actionevent)
  61.     {
  62.     txtlogin.setText("");
  63.     txtpass.setText("");
  64.     }
  65.      
  66.     public void actionPerformed(actionevent actionevent)
  67.     {
  68.     object obj = actionevent.getSource();
  69.     if(obj == ButOk)
  70.     {
  71.     ButOk_ActionPerformed(actionevent);
  72.     return;
  73.     }
  74.     if(obj == ButReset)
  75.     ButReset_ActionPerformed(actionevent);
  76.     }
  77.      
  78.     public void destroy()
  79.     {
  80.     ButOk.setEnabled(false);
  81.     ButReset.setEnabled(false);
  82.     txtlogin.setVisible(false);
  83.     txtpass.setVisible(false);
  84.     }
  85.      
  86.     public void inFile()
  87.     {
  88.     new stringbuffer();
  89.     try
  90.     {
  91.     countConn = inURL.openStream();
  92.     countData = new bufferedreader(new inputstreamreader(countConn));
  93.     string s;
  94.     while((s = countData.readLine()) != null)
  95.     if(totno < 21)
  96.     {
  97.     totno = totno + 1;
  98.     inuser[totno] = s;
  99.     s = "";
  100.     } else
  101.     {
  102.     lblstatus.setText("Cannot Exceed 10 users, Applet fail start!");
  103.     destroy();
  104.     }
  105.     }
  106.     catch(ioexception ioexception)
  107.     {
  108.     getAppletContext().showStatus("IO Error:" + ioexception.getMessage());
  109.     }
  110.     try
  111.     {
  112.     countConn.close();
  113.     countData.close();
  114.     return;
  115.     }
  116.     catch(ioexception ioexception1)
  117.     {
  118.     getAppletContext().showStatus("IO Error:" + ioexception1.getMessage());
  119.     }
  120.     }
  121.      
  122.     public void init()
  123.     {
  124.     setLayout(null);
  125.     setSize(361, 191);
  126.     add(txtlogin);
  127.     txtlogin.setBounds(156, 72, 132, 24);
  128.     label1.setText("Please Enter Login Name & Password");
  129.     label1.setAlignment(1);
  130.     add(label1);
  131.     label1.setFont(new font("Dialog", 1, 12));
  132.     label1.setBounds(41, 36, 280, 24);
  133.     label2.setText("Login");
  134.     add(label2);
  135.     label2.setFont(new font("Dialog", 1, 12));
  136.     label2.setBounds(75, 72, 36, 24);
  137.     label3.setText("Password");
  138.     add(label3);
  139.     add(txtpass);
  140.     txtpass.setEchoChar('*');
  141.     txtpass.setBounds(156, 108, 132, 24);
  142.     lblstatus.setAlignment(1);
  143.     label3.setFont(new font("Dialog", 1, 12));
  144.     label3.setBounds(75, 108, 57, 21);
  145.     add(lblstatus);
  146.     lblstatus.setFont(new font("Dialog", 1, 12));
  147.     lblstatus.setBounds(14, 132, 344, 24);
  148.     ButOk.setLabel("OK");
  149.     add(ButOk);
  150.     ButOk.setFont(new font("Dialog", 1, 12));
  151.     ButOk.setBounds(105, 156, 59, 23);
  152.     ButReset.setLabel("Reset");
  153.     add(ButReset);
  154.     ButReset.setFont(new font("Dialog", 1, 12));
  155.     ButReset.setBounds(204, 156, 59, 23);
  156.     lbltitle.setAlignment(1);
  157.     add(lbltitle);
  158.     lbltitle.setFont(new font("Dialog", 1, 12));
  159.     lbltitle.setBounds(12, 14, 336, 24);
  160.     string s = getParameter("title");
  161.     lbltitle.setText(s);
  162.     ButOk.addActionListener(this);
  163.     ButReset.addActionListener(this);
  164.     infile = new string("level4");
  165.     try
  166.     {
  167.     inURL = new url(getCodeBase(), infile);
  168.     }
  169.     catch(malformedurlexception _ex)
  170.     {
  171.     getAppletContext().showStatus("Bad Counter URL:" + inURL);
  172.     }
  173.     inFile();
  174.     }
  175.      
  176.     private url finalurl;
  177.     string infile;
  178.     string inuser[];
  179.     int totno;
  180.     inputstream countConn;
  181.     bufferedreader countData;
  182.     url inURL;
  183.     textfield txtlogin;
  184.     label label1;
  185.     label label2;
  186.     label label3;
  187.     textfield txtpass;
  188.     label lblstatus;
  189.     button ButOk;
  190.     button ButReset;
  191.     label lbltitle;
  192.     }
Add Comment
Please, Sign In to add comment