Java tutorial : How to make a simple Login program in Netbeans

in #utopian-io7 years ago (edited)

What Will I Learn?

  • We will learn about Java
  • We will learn about JFrame Form in netbeans
  • We will learn about Palletes in Netbeans
  • We will learn about jOptionpane
  • We will learn about how to make a login program using Netbeans

Requirements

  • Microsoft Windows (32 bit/64bit)
  • JDK (Latest update)
  • Netbeans IDE

Difficulty

  • Basic

Tutorial Contents

1. Basic Theory

Java is a High-Level programming language and a java program composed of parts called classes.


  • Netbeans

    image
    Image source

    Netbeans is opensource app or a free product tool for programmer to create a code, compile, troubleshoot and more. NetBeans support on any OS (Microsoft Windows, macOS, Linux and Solaris). The NetBeans platform allows program to be built from modular software components called Module. Module is a Java Archive that creates Java classes to interact with the NetBeans Open API and manifest files that identify it as a module.

  • Components used in this tutorial

a. JFrame Form


image

JFrame Form is form in design view to put any components or palettes as needed.

b. Palette


image

All components used for designing the form are placed in this section. That have been provided quite complete.


c. jOptionpane


image

To show dialog containing an information we can use jOptionpane in Netbeans.


2. Procedure
  • Step #1 : Open Netbeans
    Double click on Netbeans application in desktop, then open Netbeans :

    image

  • Step #2 : Create new project
    Click on File > New Project like in below :

    2.png

After show New Project Display, Choose Project with Categories on Java and choose Java Application in Projects , and Next :


image


  • Step #3 : Create name and location
    Create name of project in Project Name , put the project at location file to save in directory on your computer for Project Location, and then click Finish :

    image

  • Step #4 : Create new JFrame Form
    After created project and then we will create JFrame Form. First, right-click on your project (LoginForm) like in below :

    1.png

Then, create name of class in Class Name. Make sure the class name inside the LoginForm project and location on Source Packages, and click Finish :


image


  • Step #5 : Create design in JFrame Form
    Design a form with palette of Swing Controls in Palette Group. Drag and drop some palettes such as jLabel, jTextfield, jButton, jPasswordField to design in JFrame Form like image (A) in below. Then, edit the palette from image (A) into image (B) by edit and change at Font and text in Properties.

    image

  • Step #6 : Add source code
    After design, we will add source code in Login button by right-click at Login button choose Events > Mouse > mouseClicked :

    image

After moved to Source code display, add code in below jButton1MouseClicked, the code are :

  
  jTextField1.setText (" ");
jPasswordField1.setText ("");
JOptionPane.showMessageDialog(null,"Berhasil masuk", "Sukses",
jOptionPane.INFORMATION_MESSAGE); 

Show as image :


image

When you get a display below, click Ok


image


  • Step #7 : Run project
    Finally, we do the last step on this project. That is run project or run program, to run this program we have to click start in toolbars or press F6 at keyboard. Then show up as below :


image

Input username and password and then click Login button, and then appear as below :


image

Finish.


Curriculum

This is my first tutorial about Java using Netbeans



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • I don't think this teaches anything. It's too trivial.

You can contact us on Discord.
[utopian-moderator]

thank you mod @yokunjon , i could make some useful tutorial in feature.