Results 1 to 10 of 10

Thread: login page

  1. #1
    keerthi_y19 is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Default login page

    Hii all..i want to create a login page using java in which if we enter the correct user name and password it shld enter the next page...can u pls help me out in doing so

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    Is this a standalone application or is there a server involved?

  3. #3
    keerthi_y19 is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Default

    its a stand alone..if the username and password is correct it should go to next page..can we done that usings swings n applets without using jsp...

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    If there is no server involved(ie the PC isn't connected to the internet) Then your program can do anything it wants.
    I'm confused when you say "next page" and login page. That often means using the browser which means reading from a server.
    Do you want your program to communicate with a browser using the localhost address?

  5. #5
    keerthi_y19 is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Default

    sir if we enter correct username and password in the login page..the login page can be GUI,,,if we enter it correctly it should go to next form...

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    Are you sure you're not talking about a web application?
    A java program can present a window with fields for userid and password and some buttons. The program can react to the user's input and display another window. This has nothing to do with the internet. Everything would be contained in the program on the user's PC.

    If this is what you want, write a simple GUI to present a window with the input fields and buttons. If you have trouble, bring your code here and ask questions about your problem.

  7. #7
    keerthi_y19 is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Default

    This is the code i wrote for login page and its working ...but after this i'm not able to proced..actually if the login is correct i need to go to next form which has menus and other stuff...i want to know how to give connection to this login page and the next menus page so tht if the login is correct we go to tht next page...thank u..
    import java.awt.*;
    import javax.swing.*;

    public class LoginPage extends JFrame

    {

    public LoginPage()

    {

    JLabel userLabel = new JLabel ("Username:",JLabel.RIGHT);

    //Create label for user name

    userLabel.setLocation(0, 0);
    userLabel.setSize(70, 40);
    add (userLabel); //Add Label to paint
    JTextField userName = new JTextField (12); //Create field for username


    add (userName); //Add userName field to paint

    JLabel passLabel = new JLabel ("Password:",JLabel.RIGHT);
    passLabel.setLocation(0, 40);
    passLabel.setSize(70, 40);
    add (passLabel);
    JPasswordField userPass = new JPasswordField (12); //Creat field for password
    add (userPass); //Add userPass field to paint


    //Create Login button
    JButton loginButton = new JButton ("LOGIN");
    loginButton.setLocation(130, 120);
    add (loginButton);









    }


    public static void main (String [] args)

    {

    LoginPage lp= new LoginPage ();
    lp.setTitle ("LOGIN PAGE");
    lp.setLayout (new FlowLayout());
    lp.setSize (500, 250);
    lp.setVisible(true);
    lp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }

    }

  8. #8
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    6

    Default

    Hello Kirthi,
    Use a actionListener for your login button where you will creating an instance of another class and this class will have a frame with all the menus and stuff as you needed.

    You can find a lot of examples for actionListener in the net.
    To finish sooner, take your own time....
    Nivedithaaaa

  9. #9
    keerthi_y19 is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Default

    Hii..thanks for the reply ..can u please give the code how to do tht coz i'm new to java..i'll be very helpful if u can give the code

  10. #10
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    6

    Default

    Check the net kirthi, give a search for "jbutton actionlistener" , first is the best...

    Anyways m adding the same code here also and guide you about the modifications
    Java Code:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    
    public class MainClass extends JPanel {
    
      public MainClass() {
    
        JButton btn1 = new JButton("Button1");
        btn1.addActionListener(new ButtonListener());
        add(btn1);
    
      }
    
      public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().add(new MainClass());
    
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(200, 200);
        frame.setVisible(true);
      }
    }
    
    class ButtonListener implements ActionListener {
      ButtonListener() {
      }
    
      public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().equals("Button1")) {
          System.out.println("Button1 has been clicked");
        }
      }
    }
    Here instead of "System.out.println("Button1 has been clicked");"
    you will be creating an instance of another class say MySecondClass as follows

    Java Code:
    MySecondClass secondClass = new MySecondClass();
    secondClass.myFrame();
    and MySecondClass would extend JFrame and would look something like this
    Java Code:
    public class MySecondClass extends JFrame {
    
      public MySecondClass() {
      }
    
      public void myFrame{
          //Code for adding menu's and rest of the things
       }
    }
    To finish sooner, take your own time....
    Nivedithaaaa

Similar Threads

  1. Need to return to login page once logout
    By peiceonly in forum Suggestions & Feedback
    Replies: 2
    Last Post: 03-31-2009, 07:50 PM
  2. Login page
    By banie in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-03-2008, 02:05 PM
  3. Replies: 0
    Last Post: 06-25-2008, 12:41 PM
  4. problems with my JSP login page
    By ilangocal in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-28-2008, 06:40 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
  •