How To Create A Simple Registration Form Using Java AWT

in #utopian-io4 years ago (edited)

What Will I Learn?

  • You will learn about AWT
  • You will learn about GUI
  • You will learn about Java programming
  • You will learn about how to create GUI application using AWT

Requirements

Difficulty

  • Intermediate

Tutorial Contents

This time, I will show you how to create a simple registration form using Java AWT feature. Of course, I will make it in GUI form.

First you must know the meaning of AWT. AWT (Abstract Windowing Toolkit) is a feature in java that provides multiple classes for creating GUI views. AWT is almost similar to SWING, it's just AWT display is simpler than SWING.

For a bit of reference too, GUI is an interface view. Its function is to facilitate the user in accessing the computer.

Now you can see the steps.

  • The first step is to create a file named Tes.java. Then, you can simply fill the command (syntax) into the file.

Enter the command to call the AWT java feature.

import java.awt.*;

Next is to give the name of the public class. The public class name must be the same as the java file name you created. And since you will use AWT, then in public class we have to put command to call applet feature, so you can display GUI form.

public class Tes extends java.applet.Applet

Next, enter a command to call the method. This time we use init method, because it is more suitable with the GUI application using AWT.

public void init() 
{

The next is to make layout settings, so the application will be created will appear from the left layout.

setLayout(new FlowLayout(FlowLayout.LEFT));

Then, enter the command add (new Label ("Name:")); to create a new label. And command add(new TextField (10)); to create a field that can be filled using text.

add(new Label("Name          :"));
add(new TextField(10));

add(new Label("Address       :"));
add(new TextField(10));
        
add(new Label("Birthday      :"));
add(new TextField(10));

Syntax below is a syntax to create an other label and a choice menu. The choise menu can be created using the command Choice gender = new Choice(); . The choice menu may contain some contents. The example is in the choice of gender.

add(new Label("Gender        :"));
Choice gender = new Choice(); 
gender.addItem("Man"); 
gender.addItem("Woman"); 
Component add = add(gender);  

While the command below is a command to create a new label and a checkbox option. Checkbox options are formed using command CheckboxGroup job = new CheckboxGroup();.

add(new Label("Job            :"));
CheckboxGroup job = new CheckboxGroup();
add(new Checkbox("Student", job, false));
add(new Checkbox("Teacher", job, false));

And the syntax below serves to create buttons. In the form of Register and Exit button.

add(new Button("Register"));
add(new Button("Exit"));
}
}
  • Then, do not forget to create the Tes.html file. This is very useful, so that you can display the result of your application. The syntax is as follow.
<html>
<head><title>Register</title></head>
<body>
<applet code="Tes.class" width=230 height=300></applet>
</body>
</html>
  • And now, you can try to run its application.

Compiling process:

image.png

Registration Form result:

image.png

Final result:

image.png

Here are the full syntax.

  • Tes.java
import java.awt.*;
public class Tes extends java.applet.Applet 
{
    public void init() 
    {
        
        setLayout(new FlowLayout(FlowLayout.LEFT));
        
        add(new Label("Name          :"));
        add(new TextField(10));

        add(new Label("Address       :"));
        add(new TextField(10));
        
        add(new Label("Birthday      :"));
        add(new TextField(10)); 
        

        add(new Label("Gender        :"));
        Choice gender = new Choice(); 
        gender.addItem("Man"); 
        gender.addItem("Woman"); 
        Component add = add(gender); 

        add(new Label("Job            :"));
        CheckboxGroup job = new CheckboxGroup();
        add(new Checkbox("Student", job, false));
        add(new Checkbox("Teacher", job, false));
                
        add(new Button("Register"));
        add(new Button("Exit"));
        }
}
  • Tes.html
<html>
<head><title>Register</title></head>
<body>
<applet code="Tes.class" width=230 height=300></applet>
</body>
</html>

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

I am sure,
It will be approved

I hope like that so :v

Don't worry, the words in your post can be understood

Thank you for the contribution. It has been approved.

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

Hey @mauliza11 I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • This is your first accepted contribution here in Utopian. Welcome!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Simple and to the point, nice work pal, keep it up

Coin Marketplace

STEEM 0.29
TRX 0.06
JST 0.040
BTC 36523.15
ETH 2440.31
USDT 1.00
SBD 4.00