0% found this document useful (0 votes)
27 views

Java Part A & B

Uploaded by

walkevarad66
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Java Part A & B

Uploaded by

walkevarad66
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

PART A – Micro Project Proposal

Title - Login and Registration Form using Java AWT and Swing

1.0 Brief Introduction

Java AWT is an API that contains large number of classes and methods to create and manage
graphical user interface (GUI) applications. The AWT was designed to provide a common set of
tools for GUI design that could work on a variety of platforms. The tools provided by the AWT are
implemented using each platform's native GUI toolkit, hence preserving the look and feel of each
platform. This is an advantage of using AWT. But the disadvantage of such an approach is that
GUI designed on one platform may look different when displayed on another platform that means
AWT component are platform dependent.

AWT is the foundation upon which Swing is made i.e., Swing is an improved GUI API that
extends the AWT. But now a days AWT is merely used because most GUI Java programs are
implemented using Swing because of its rich implementation of GUI controls and lightweighted
nature.

2.0 Aim of the Micro-Project –

The aim of this micro-project is to develop a Login and Registration Form program with
the help of java and AWT command-lines, and implement it successfully. This program is a simple
form page where you can enter your name and select gender using the radio-button and select age
then click on the button. Here you can find different options to select of age among that you can
select anyone.

3.0 Intended Course Outcomes

a) Create Login and Registration form using AWT and Swing.

b) used to enter authentication credentials to access a restricted page or form.

1
4.0 Literature Review –

In Java, a form for entering authentication credentials to access the restricted page is referred
to as a Login form. A login form contains only two fields, i.e., username and password. Each user
should have a unique username that can be an email, phone number, or any custom username.

After submitting the login form, the underlying code of the form checks whether the credentials
are authentic or not to allow the user to access the restricted page. If the users provide unauthentic
credentials, they will not be able to forward the login form.
Swing is a part of the JFC (Java Foundation Classes). Building Graphical User Interface in Java
requires the use of Swings. Swing Framework contains a large set of components which allow a
high level of customization and provide rich functionalities, and is used to create window-based
applications. Java swing components are lightweight, platform-independent, provide powerful
components like tables, scroll panels, buttons, list, color chooser, etc.
In this article, we’ll see how to make Registration form which includes all the buttons and field in
one Form.

5.0 Proposed Methodology –

1) In this microproject, first of all we have focused on selection of appropriate topic for our micro
project.

2) Select the topic i.e. Login and Registration form using java awt and swing.

3) Then we started with our brief study as well as a survey on our topic.

4) Then we gathered all information based on the topic of microproject.

5) We have done analysis and study of our topic in detail.

6) All the above methodologies we successfully completed with our microproject.

2
6.0 Resources Required –

Sr. No Name of Software Specifications

1 Sublime text Version 4

2 Netbeans ide Version 8.2

3
7.0 Action Plan –

Sr. No Details of Activity Planned Planned Name of Responsible

Team Members
Start Date Finish

Date

1 Project Proposal All Members

2 Data collection and Analysis


All Members

3 Preparation of Report All Members

4
PART B – Micro Project Report

Login and Registration Form using Java AWT and Swing

1.0 Rationale

Java AWT is an API that contains large number of classes and methods to create and manage
graphical user interface (GUI) applications. The AWT was designed to provide a common set
of tools for GUI design that could work on a variety of platforms. The tools provided by the
AWT are implemented using each platform's native GUI toolkit, hence preserving the look and
feel of each platform. This is an advantage of using AWT. But the disadvantage of such an
approach is that GUI designed on one platform may look different when displayed on another
platform that means AWT component are platform dependent.

AWT is the foundation upon which Swing is made i.e., Swing is an improved GUI API that
extends the AWT. But now a days AWT is merely used because most GUI Java programs are
implemented using Swing because of its rich implementation of GUI controls and lightweighted
nature.

2.0 Intended Course Outcomes

a) Create Login and Registration form using AWT and Swing.

b) used to enter authentication credentials to access a restricted page or form.

3.0 Literature Review

In Java, a form for entering authentication credentials to access the restricted page is referred
to as a Login form. A login form contains only two fields, i.e., username and password. Each user
should have a unique username that can be an email, phone number, or any custom username.

After submitting the login form, the underlying code of the form checks whether the credentials
are authentic or not to allow the user to access the restricted page. If the users provide unauthentic
credentials, they will not be able to forward the login form.

5
Swing is a part of the JFC (Java Foundation Classes). Building Graphical User Interface in Java
requires the use of Swings. Swing Framework contains a large set of components which allow a
high level of customization and provide rich functionalities, and is used to create window-based
applications. Java swing components are lightweight, platform-independent, provide powerful
components like tables, scroll panels, buttons, list, color chooser, etc.
In this article, we’ll see how to make Registration form which includes all the buttons and field in
one Form.

4.0 Proposed Methodology

1) In this microproject, first of all we have focused on selection of appropriate topic for our micro
project.

2) Select the topic i.e., Login and Registration form using java awt and swing.

3) Then we started with our brief study as well as a survey on our topic.
4) Then we gathered all information based on the topic of microproject.

5) We have done analysis and study of our topic in detail.

6) All the above methodologies we successfully completed with our microproject.

5.0 Resources Required

Sr. No Name of Software Specifications

1 Sublime text Version 4

2 Netbeans ide Version 8.2

6
6.0 Outputs of the Micro Project

Source-Code

Login Form

import java.awt.*;
import java.awt.event.*;
import java.io.*;
class form extends Frame implements ActionListener
{
private Label fname_lbl,lname_lbl,address_lbl,e_mailid_lbl;
private TextField
fname_txt,lname_txt,address_txt,e_mailid_txt; private Button
submit_btn,exit_btn,clear_btn,save_btn; private TextArea
area_txta; public form()
{
setBackground(Color.LIGHT_GRAY);
setLayout(null);

setTitle("Applicatoin Form");
setSize(650,350);
setLocation(100,100);

/*-------------Labels------------*/

fname_lbl=new Label("First Name");


fname_lbl.setBounds(25,100,100,30);
add(fname_lbl);

lname_lbl=new Label("Last Name");


lname_lbl.setBounds(25,150,100,30);
add(lname_lbl);

address_lbl=new Label("Address");
address_lbl.setBounds(25,200,100,30);
add(address_lbl);

e_mailid_lbl=new Label("E-MailID");
e_mailid_lbl.setBounds(25,250,100,30);
add(e_mailid_lbl);

7
/*---------------TextField----------*/

fname_txt=new TextField();
fname_txt.setBounds(125,100,150,30);
add(fname_txt);

lname_txt=new TextField();
lname_txt.setBounds(125,150,150,30);
add(lname_txt);

address_txt=new TextField();
address_txt.setBounds(125,200,150,30);
add(address_txt);

e_mailid_txt=new TextField();
e_mailid_txt.setBounds(125,250,150,30);
add(e_mailid_txt);

/*-----------------Button------------*/
submit_btn=new Button("Submit");
submit_btn.setBounds(25,300,75,30);
submit_btn.addActionListener(this);
add(submit_btn);

clear_btn=new Button("Clear");
clear_btn.setBounds(125,300,75,30);
clear_btn.addActionListener(this);
add(clear_btn);

exit_btn=new Button("Exit");
exit_btn.setBounds(225,300,75,30);
exit_btn.addActionListener(this); add(exit_btn);

save_btn=new Button("Save");
save_btn.setBounds(450,300,75,30);
save_btn.addActionListener(this);
add(save_btn);

/*--------------TextArea-----------------*/

area_txta=new TextArea();
area_txta.setBounds(350,100,275,180);
add(area_txta);

/*---------------------------------------*/

8
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});

}
public void paint(Graphics g)
{
g.setFont(new Font("Informal Roman",Font.BOLD,30));
g.setColor(Color.blue);
g.drawString("Application Form",75,80);

g.setFont(new Font("Informal Roman",Font.BOLD,30));


g.setColor(Color.blue);
g.drawString("Data",450,80);

g.drawLine(325,25,325,325);
g.drawLine(330,25,330,325);
}

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource()==submit_btn)
{
String str_fname=fname_txt.getText();
String str_lname=lname_txt.getText();
String str_add=address_txt.getText();
String str_e_mailid=e_mailid_txt.getText();

area_txta.setText("\n\n"+"First Name - "+str_fname+"\n\n"+"Last Name -


"+str_lname+"\n\n"+"Address - "+str_add+"\n\n"+"E-mail Id"+str_e_mailid+"\n\n");
}
else if(ae.getSource()==exit_btn)
{
new MyDialog111().setVisible(true);
}
else if(ae.getSource()==clear_btn)
{ fname_txt.setText(" ");
lname_txt.setText(" ");
address_txt.setText(" ");

9
e_mailid_txt.setText("
"); area_txta.setText(" ");
}
else if(ae.getSource()==save_btn)
{
try
{
FileOutputStream fos=new FileOutputStream("swati.txt",true);
DataOutputStream dos=new DataOutputStream(fos);
String str2="\n";
String str1=area_txta.getText();
dos.writeChars(str1+str2);
dos.close();
}
catch(Exception e){}
}
}

}
class MyDialog111 extends Dialog implements ActionListener
{ private Label lbl_msg; private
Button btn_yes,btn_no; private Panel
north_panel,south_panel;
public MyDialog111()
{
super(new form(),"Dialog
Demo",true); north_panel=new
Panel(); south_panel=new Panel();

setTitle("Confirm Close"); setSize(200,200);


setLocation(50,80); lbl_msg=new Label("Do
you want to Close?"); btn_yes=new
Button("Yes");
btn_no=new Button("No");

north_panel.add(lbl_msg);
south_panel.add(btn_yes);
south_panel.add(btn_no);
add(north_panel,"North");
add(south_panel,"South");
btn_yes.addActionListener(this);
btn_no.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{

10
if(ae.getSource()==btn_yes)
{
System.exit(0)
; } else
dispose(); } }
class IOForm
{
public static void main(String []args)
{
new form().setVisible(true);
}
}

11
Registration Form

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class MyFrame
extends JFrame
implements ActionListener {

// Components of the Form private


Container c; private JLabel title;
private JLabel name; private
JTextField tname; private JLabel
mno; private JTextField tmno;
private JLabel gender; private
JRadioButton male; private
JRadioButton female; private
ButtonGroup gengp; private JLabel
dob; private JComboBox date;
private JComboBox month; private
JComboBox year; private JLabel
add; private JTextArea tadd;
private JCheckBox term; private
JButton sub; private JButton reset;
private JTextArea tout; private
JLabel res;
private JTextArea resadd;

private String dates[]


= { "1", "2", "3", "4", "5",
"6", "7", "8", "9", "10",
"11", "12", "13", "14", "15",
"16", "17", "18", "19", "20",
"21", "22", "23", "24", "25",
"26", "27", "28", "29", "30",
"31" };
private String months[]
= { "Jan", "feb", "Mar", "Apr",
"May", "Jun", "July", "Aug",
"Sup", "Oct", "Nov", "Dec" };

12
12
private String years[]
= { "1995", "1996", "1997", "1998",
"1999", "2000", "2001", "2002",
"2003", "2004", "2005", "2006",
"2007", "2008", "2009", "2010",
"2011", "2012", "2013", "2014",
"2015", "2016", "2017", "2018",
"2019" };

// constructor, to initialize the components


// with default values. public MyFrame()
{
setTitle("Registration Form"); setBounds(300, 90,
900, 600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);

c = getContentPane();
c.setLayout(null);

title = new JLabel("Registration Form"); title.setFont(new


Font("Arial", Font.PLAIN, 30));
title.setSize(300, 30);
title.setLocation(300, 30);
c.add(title);

name = new JLabel("Name"); name.setFont(new


Font("Arial", Font.PLAIN, 20));
name.setSize(100, 20);
name.setLocation(100, 100);
c.add(name);

tname = new JTextField();


tname.setFont(new Font("Arial", Font.PLAIN, 15));
tname.setSize(190, 20);
tname.setLocation(200, 100);
c.add(tname);

mno = new JLabel("Mobile"); mno.setFont(new


Font("Arial", Font.PLAIN, 20));
mno.setSize(100, 20);
mno.setLocation(100
, 150); c.add(mno);
tmno = new
JTextField();

13
tmno.setFont(
new Font("Arial",
Font.PLAIN, 15));
tmno.setSize(150, 20);
tmno.setLocation(200, 150);
c.add(tmno);

gender = new JLabel("Gender"); gender.setFont(new


Font("Arial", Font.PLAIN, 20)); gender.setSize(100, 20);
gender.setLocation(100, 200);
c.add(gender);

male = new JRadioButton("Male"); male.setFont(new


Font("Arial", Font.PLAIN, 15));
male.setSelected(true);
male.setSize(75, 20);
male.setLocation(200, 200);
c.add(male);

female = new JRadioButton("Female"); female.setFont(new


Font("Arial", Font.PLAIN, 15)); female.setSelected(false);
female.setSize(80, 20);
female.setLocation(275, 200);
c.add(female);

gengp = new ButtonGroup();


gengp.add(male);
gengp.add(female);

dob = new JLabel("DOB"); dob.setFont(new


Font("Arial", Font.PLAIN, 20));
dob.setSize(100, 20);
dob.setLocation(100, 250);
c.add(dob);

date = new JComboBox(dates); date.setFont(new


Font("Arial", Font.PLAIN, 15)); date.setSize(50, 20);
date.setLocation(200, 250);
c.add(date);

month = new JComboBox(months);


month.setFont(new Font("Arial",
Font.PLAIN, 15)); month.setSize(60, 20);
month.setLocation(250, 250); c.add(month);

14
year = new JComboBox(years); year.setFont(new
Font("Arial", Font.PLAIN, 15)); year.setSize(60,
20);
year.setLocation(320, 250);
c.add(year);

add = new JLabel("Address"); add.setFont(new


Font("Arial", Font.PLAIN, 20)); add.setSize(100, 20);
add.setLocation(100, 300); c.add(add);

tadd = new JTextArea();


tadd.setFont(new Font("Arial", Font.PLAIN, 15));
tadd.setSize(200, 75); tadd.setLocation(200, 300);
tadd.setLineWrap(true);
c.add(tadd);

term = new JCheckBox("Accept Terms And Conditions.");


term.setFont(new Font("Arial", Font.PLAIN, 15));
term.setSize(250, 20);
term.setLocation(150, 400);
c.add(term);

sub = new JButton("Submit"); sub.setFont(new


Font("Arial", Font.PLAIN, 15));
sub.setSize(100, 20);
sub.setLocation(150, 450);
sub.addActionListener(this);
c.add(sub);

reset = new JButton("Reset"); reset.setFont(new


Font("Arial", Font.PLAIN, 15));
reset.setSize(100, 20);
reset.setLocation(270, 450);
reset.addActionListener(this);
c.add(reset);

tout = new JTextArea();


tout.setFont(new Font("Arial", Font.PLAIN, 15));
tout.setSize(300, 400);
tout.setLocation(500, 100);
tout.setLineWrap(true);
tout.setEditable(false);
c.add(tout);

res = new JLabel("");

15
res.setFont(new Font("Arial", Font.PLAIN, 20)); res.setSize(500,
25);
res.setLocation(100, 500);
c.add(res);

resadd = new JTextArea();


resadd.setFont(new Font("Arial", Font.PLAIN, 15));
resadd.setSize(200, 75); resadd.setLocation(580, 175);
resadd.setLineWrap(true);
c.add(resadd);

setVisible(true);
}

// method actionPerformed()
// to get the action performed // by the user
and act accordingly public void
actionPerformed(ActionEvent e)
{
if (e.getSource() == sub) {
if (term.isSelected()) {
String data1;
String data
= "Name : "
+ tname.getText() + "\n"
+ "Mobile : "
+ tmno.getText() + "\n"; if (male.isSelected())
data1 = "Gender : Male"
+
"\n"; else
data1 = "Gender : Female"
+ "\n";
String data2
= "DOB : "
+ (String)date.getSelectedItem()
+ "/" +
(String)month.getSelectedItem() + "/"
+ (String)year.getSelectedItem()
+ "\n";

String data3 = "Address : " + tadd.getText(); tout.setText(data +


data1 + data2 + data3); tout.setEditable(false);
res.setText("Registration Successfully..");
}
else { tout.setText("");

16
resadd.setText("");
res.setText("Please accept the"
+ " terms & conditions..");
}
}

else if (e.getSource() == reset) {


String def = "";
tname.setText(def);
tadd.setText(def);
tmno.setText(def);
res.setText(def);
tout.setText(def);

term.setSelected(false);
date.setSelectedIndex(0);

month.setSelectedIndex(0);
year.setSelectedIndex(0);
resadd.setText(def);
}
}
}

// Driver
Code class
Registration
{

public static void main(String[] args) throws Exception


{
MyFrame f = new MyFrame();
}
}

17
Login Form

Registration Form

7.0 Skill Developed / learning out of this Micro Project

You might also like