Results 1 to 4 of 4

Thread: help needed

  1. #1
    Join Date
    Jan 2010
    Posts
    72
    Rep Power
    0

    Default help needed

    i am designing a login form on swing where the user has to enter name and password and submit via button

    if the user enters wrong password i want to display a pop window to show his login failure just like the alert() funtion of javascript...is there any way of doing it.....
    any reply will be highly appreciated

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,365
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by silversurfer2in View Post
    i am designing a login form on swing where the user has to enter name and password and submit via button

    if the user enters wrong password i want to display a pop window to show his login failure just like the alert() funtion of javascript...is there any way of doing it.....
    any reply will be highly appreciated
    Read the API documentation for the JTextField, the JPasswordField, the JButton, the JDialog (or the JOptionPane) and the ActionListener classes.

    kind regards,

    Jos

  3. #3
    wzq110120 is offline Member
    Join Date
    May 2010
    Location
    china
    Posts
    7
    Rep Power
    0

    Default

    I don't what are you say.

  4. #4
    mr_anderson is offline Member
    Join Date
    May 2010
    Location
    Florida
    Posts
    68
    Rep Power
    0

    Default Check this code

    Hi
    I am not sure if I understood your question, but I wrote this code
    I donot know if this is what you want:
    Java Code:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    
    public class NFrame extends JFrame{
        JButton submit=new JButton("submit");
        JLabel lUser=new JLabel("username");
        JTextField user=new JTextField(8);
        JLabel lPass=new JLabel("password");
        JPasswordField password=new JPasswordField(8);
        JPanel panel=new JPanel();
        public NFrame(){
            panel.add(lUser);
            panel.add(user);
            panel.add(lPass);
            panel.add(password);
            panel.add(submit);
            submit.addActionListener(new ActionListener(){
    
                public void actionPerformed(ActionEvent e) {
                String userr=user.getText();
                String passs=password.getText();
                // suppose user name is pop and password is 123456
                if(userr.equals("pop") && (passs.equals("123456"))){
                    JOptionPane.showMessageDialog(null," your user and password are accepted");
                }
                else
                    JOptionPane.showMessageDialog(null,"sorry wrong user and pass");
                }
            });
            add(panel);
            setSize(400,400);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setAlwaysOnTop(true);
            setVisible(true);
        }
        public static void main(String [] args){
            new NFrame();
        }
    }
    Regards.

Similar Threads

  1. Help needed
    By saibru in forum CLDC and MIDP
    Replies: 0
    Last Post: 03-23-2009, 09:40 AM
  2. help needed!!! :S
    By mark-mlt in forum Networking
    Replies: 1
    Last Post: 04-14-2008, 09:27 AM
  3. Help needed.
    By necro-1000 in forum AWT / Swing
    Replies: 2
    Last Post: 01-12-2008, 11:37 AM
  4. Help Needed
    By pks in forum New To Java
    Replies: 1
    Last Post: 01-09-2008, 12:07 AM
  5. help needed.
    By dirtycash in forum New To Java
    Replies: 3
    Last Post: 12-03-2007, 09:17 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
  •