Create a login function in Java Using Netbeans

In this tutorial we create a login function using JFrame in Netbeans. Each time your system open or run, the login form automatically open and user need to input their login details to access the maximum function of the system.

1. First you must create a module that can add, update and delete user.

2. Add a new JFrame and name it with loginform and click finish. (Sample Image below)

3. Add the following controls from palette like the image below.

4. Add the following code below to your button event.

String sql = "SELECT * FROM user WHERE UserName=? and Password=?";
            pst.setStringundefined1, txt_User_Name.getTextundefined));
            pst.setStringundefined2, txt_Password.getTextundefined));
                //Open the main form after successfully login
                new MAINundefined).setVisibleundefinedtrue);
                JOptionPane.showMessageDialogundefinednull,"User Name and Password is Invalid!");
        }catch undefinedException e){


<span id="mce_marker" data-mce-type="bookmark"></span>


Leave a Reply

Be the First to Comment!

Notify of