Skip to content
June 23, 2026
  • Privacy Policy
  • Terms & Conditions
  • Write For Us

Eduonix Blog

Learn and Build Your Skills

KS_AI-For-Kids_696_90
Primary Menu
  • Privacy Policy
  • Terms & Conditions
  • Write For Us
  • Home
  • 2016
  • November
  • Learn To Create A Login Page Class Form In Java Using Netbeans
  • Java Programming

Learn To Create A Login Page Class Form In Java Using Netbeans

Tutor @ Eduonix November 26, 2016 5 minutes read
Login Page Class

In this article, we will be learning how to create a login form in Java using NetBeans.

Installation of NetBeans

The Java SE Development Kit(JDK) 7 or JDK 8 is required to install the NetBeans IDE.
Now, download the latest NetBeans IDE from its official channel. Download the whole IDE bundle version depending upon your processor architecture. The user can add or remove the packs using the IDE’s Plugin Manager. You can check out the steps to install and use NetBeans in this article.
netbeans-ide
Assume that you have successfully installed NetBeans on your machine. Start the NetBeans from the Window. The NetBeans main window will appear as shown below.
demo
The NetBeans main window contains menus, toolbars, the project pane, the files pane, the runtime pane, the navigator pane, and other panes. The NetBeans main window is the command center for the IDE.

Read More: Jobs In Demand For 2020 & Beyond: 15 Careers You Can’t Ignore!!

Creating a blank Project
To create and run a program, you have to first create a project.
Here are the steps to create a demo project

Step 1: – Choose File and New Project to display the New Project dialog box.
new-project
The new project box enables you to specify the project type.
Step 2: – Choose the Java type from the given list.
Step 3: – From the New Application Tab, enter the project name and unselect the main class from it.

Login Form
These steps are to be followed.

Step 1: – Create a blank Java project with the name loginpageclassy. Uncheck the Main class option from the project tab. Note down the address of the directory and download any image for a background and login label and for the header a shown below.
Step2: – To add a JFrame, right-click the project name in the Project window.
project-window
Step 3: – Now right-click the JFrame, click Set Layout and select Null Layout from the option.
Step 4: – Open the project folder and drag those images into the project field as shown below.
project-field
Step5: – Now drag a label field from the palette. Right-click on the Jlabel button and select icons, where you can select the image for that particular label. Make this label the background of the project by extending it to all the four corners of the JFrame.
Step6: – Right-click on the label field to enter into the Properties and select the icon to set the custom icon for the label. Make this label the background of the project by extending it to all the four corners of the JFrame.
Step7: – Now drag a Text Field and a Password Field from the Pallette into the JFrame. Now, Drag three more labels into the JFrame for labeling the Username, Password and for the Login button.
Step8: – Set the Text field and the Password field to empty. Rename the label for the Username and the Password. Therefore the whole form appears as below.
login-page
Step9: – Now, Right-click on to the Login button and select Events >>Mouse >>Mouse Click.
This will direct it to the Source section.

Source Coding
A string ‘ext’ is declared in order to get the text entered into the Password field. The text entered in the text field and the password field is compared with the Username and the password, which has been set already. If the text entered in both the fields match with the previously saved ones, the user gets a pop-up message showing that the Login was successful, else a Login Failed message will appear.
password-field
Right-click on to the Login button and select Events >>Mouse >>Mouse Click.
This will direct to the below statement in the Source section.

private void jLabel3MouseClicked(java.awt.event.MouseEvent evt)

Declaration of string and coding for the comparing Username and Password.
The diagram below lists the purpose of each statement used in this logic.
statement
Now, Save the program and click the Run button.

The Login form will be shown. Enter the Username and Password correctly. This gives a message tab showing that the login was successful.
successful-login
If the Username or the password entered is wrong, the screen shown below appears.
login-failed

Now that you have successfully learned to build an impressive login page, you can also try making other projects such as creating a basic calculator in Java using Netbeans. Also, if you want to build more projects in Java as a beginner, try “Learn Projects in Java for Beginners from Scratch” online course absolutely FREE!

We hope that this article has helped you in understanding the basics of creating a Login Form. Feel free to contact us in case if you face any issues regarding the same.

People Are Also Reading:

  • 10 Ways to Learn Java in just a Couple of Weeks
  • Is It Possible to Use Java with iOS?
  • Docker for Java Development Environment With Ubuntu

Latest Updates On Coronavirus

  • Using Various Technologies To Prevent Coronavirus!!
  • How Tech-Giants Are Using Technology to Fight COVID-19?
  • Coronavirus Impact on Top Tech Conferences Around the World

About the Author

Tutor @ Eduonix

Administrator

View All Posts

Post navigation

Previous: Learn how to Write Angular 2 Code in ES5
Next: Learn Docker Swarm and Implementing Scalability on Multiple Hosts

14 thoughts on “Learn To Create A Login Page Class Form In Java Using Netbeans”

  1. iamezcua.dev says:
    December 23, 2017 at 3:47 am

    Ok, this works but, what if I don’t want to hardcode the password and I would want to store/update the users and passwords using a relational database. What would be the best way to achieve this? Regards.

    Reply
    1. Radhika says:
      January 9, 2020 at 4:48 pm

      Use JDBC to connect to the data base and then get the table details onto your form.

      Reply
  2. Neha says:
    March 8, 2018 at 8:15 am

    i know nothing, i want details of it from base part. Where can it be available?

    Reply
    1. kit says:
      March 30, 2018 at 8:52 am

      same…

      Reply
  3. kay says:
    April 9, 2018 at 4:18 pm

    this is no aid for beginners.

    Reply
  4. Norwel says:
    February 2, 2019 at 10:25 am

    m a beginner in java and i knw nothing how can i be helped or is there any othr platform say whatsapp where i can get help from

    Reply
  5. Nele says:
    April 13, 2019 at 12:09 pm

    The question say load array with login detail .the user will input his or her logins on textfield..if logins deatails input by user match with the one populated on the array , display accurate message.
    NB using jframe on NetBeans

    Reply
  6. Rohit Raj says:
    May 10, 2019 at 4:54 am

    Every thing i understand but in password textbox there’s “*****” where it is came from

    Reply
  7. Tikaram Acharya says:
    July 15, 2019 at 3:01 pm

    by using passworld field instead of textfield

    Reply
  8. Nirmit Aggarwal says:
    July 31, 2019 at 11:54 am

    It is because you use JPasswordField

    Reply
  9. sagari says:
    January 30, 2020 at 2:56 am

    thank you..
    now how can i make a login form with 2 diferent user and 2 different main menu according to the user level.

    thanks

    Reply
  10. sravya says:
    February 7, 2020 at 2:53 am

    how can i get code for this?

    Reply
  11. Rica says:
    February 17, 2020 at 2:02 am

    Code please

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Articles

Capture
  • Java Programming
  • Perl Programming
  • System Programming

Find Out Top 5 Computer Programming Scholarships to Apply for in 2023-2024

Tutor @ Eduonix August 23, 2023
Why Java Application Development is Necessary for Growing Businesses?
  • Business
  • Java Programming

Why Java Application Development is Necessary for Growing Businesses?

Tutor @ Eduonix October 13, 2021
JavaScript Programming - A Complete Guide for Beginners
  • Java Programming

JavaScript Programming – A Complete Guide For Beginners

Tutor @ Eduonix September 23, 2021
Copyright © Eduonix Learning Solutions. All rights reserved. | MoreNews by AF themes.