Results 1 to 5 of 5
  1. #1
    alex164 is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default to create a login page

    can anyone help me
    i am a student of computer science yet in 2nd year
    i am trying to create a login page in java , but i am getting problem in it
    actually i have to create a login page in which the condition is tht if i write the correct username and password then it will show tht you are successfully loged in and if i enter 3 time wrong username or password then it will show msg tht you have entered wrong username or password and the page will be exit means close automatically
    i have wriiten this code and executed it but i need help coz it now working properly please help if you can
    here is the code which i have written thanks
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;

    public class login extends Applet implements ActionListener
    {
    TextField t,t1;
    String s3;
    Label name,pass;
    Button b;
    public void init()
    {

    Label name =new Label("username");
    add(name);

    t=new TextField(20);
    add(t);

    Label pass =new Label("password");
    add(pass);

    t1=new TextField(20);
    add(t1);
    t1.setEchoChar('*');

    Button b = new Button("login");
    add(b);

    b.addActionListener(this);
    }


    public void actionPerformed(ActionEvent ae)
    {
    String str =ae.getActionCommand();

    String s1=t.getText();
    String s2=t1.getText();
    int i=1;

    {
    if(s1.equals("alex") && s2.equals("abc"))
    {
    s3="welcome to manav rachna international university";
    t.setText("");
    t1.setText("");
    repaint();
    }

    else
    {
    i++;
    t.setText("");
    t1.setText("");}

    if(i==3)
    System.exit(0);
    }
    }

    public void paint(Graphics g)
    {

    g.drawString(s3,500,400);

    }
    }

  2. #2
    alex164 is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: to create a login page

    can anyone help me ?

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default Re: to create a login page

    Please use [code] tags [/code] when posting code.
    You also need to tell us what "not working" means.
    Errors?
    Incorrect output?
    What?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default Re: to create a login page

    Firstly you don't need to declare the labels, buttons, text fields, etc like other variables. Then the source code is missing. So you can start like:

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;

    /*
    <applet code="Login" width=500 height=500>
    </applet>
    */

    public class Login extends Applet impements ActionListener
    {
    Label l1 = new Label("Username : ");
    Label l2 = new Label("Password : ");
    TextField t1 = new TextField(10);
    TextField t2 = new TextField(10);
    Button b = new Button("Login");

    public void init()
    {
    add(l1);
    add(t1);
    add(l1);
    add(t2);
    add(b);
    }
    ......... //now you can continue with your logic and run this program in "Applet Viewer". Hope this helped you. :)

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: to create a login page

    Quote Originally Posted by software engineer View Post
    Firstly you don't need to declare the labels, buttons, text fields, etc like other variables. Then the source code is missing. So you can start like:

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;

    /*
    <applet code="Login" width=500 height=500>
    </applet>
    */

    public class Login extends Applet impements ActionListener
    {
    Label l1 = new Label("Username : ");
    Label l2 = new Label("Password : ");
    TextField t1 = new TextField(10);
    TextField t2 = new TextField(10);
    Button b = new Button("Login");

    public void init()
    {
    add(l1);
    add(t1);
    add(l1);
    add(t2);
    add(b);
    }
    ......... //now you can continue with your logic and run this program in "Applet Viewer". Hope this helped you. :)
    Don't post to old dead threads.

    Do read any thread in which you feel urged to post a response. The post just above yours mentions the code tags.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. create login page and how to java application
    By srinivas2939 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 12-06-2011, 07:30 PM
  2. login page
    By banie in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-09-2008, 09:37 AM
  3. login page
    By keerthi_y19 in forum New To Java
    Replies: 9
    Last Post: 08-06-2008, 12:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •