We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

impove my code. i think it is helpful 4 those to whom that required solution.

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

public class GUI implements ActionListener
{
ArrayList personsList;
PersonDAO pDAO;

JFrame myFrame;

// labels
JLabel lNIC Card, lFather/Husband'sName, lAge, lAddress, lProvance;

// text fields
JTextField tfNIC Card, tfFather/Husband'sName, tfAge, tfAddress, tfProvance;

// buttons
JButton bSave, bExit;

String Father/Husband'sname, address, Provance;
int NIC Card, Age;


//*************************************************************************************
/*GUI Constructor*/
public GUI()
{
NIc Card = "";
FAther/HUsband's Name = "";
Age = "";
Address = "";
provance = "";

recordNumber = -1;

initGUI();

personsList = new ArrayList();

// creating PersonDAO object
pDAO = new PersonDAO();
}

//*****************************************************************************************
/*initGui function will initialize our GUI*/
public void initGUI()
{

/*Create a frame, get its contentpane and set layout*/
myFrame = new JFrame("Voter Registration Form");

Container c = myFrame.getContentPane();
c.setLayout(new FlowLayout());

/*initializing labels*/
lNIC Card = new JLabel("NIC Card");
lFather/HUsband's Name = new JLabel("Father/HUsband's Name");
lAge = new JLabel("Age");
lAddress = new JLabel("Address");
lProvance = new JLabel("provance");

/*initializing text fields*/
tfNIC Card = new JTextField(20);
tfFather'Husband's Name = new JTextField(20);
tfAge = new JTextField(20);
tfAddress = new JTextField(20);
tfProvance = new JTextField(20);


/* intializing buttons */
bSave = new JButton("Save");
bExit = new JButton("Exit");

/*add all initialized components to the container*/
c.add(lNIC Card);
c.add(tfNIC Card);

c.add(lFather/Husband's Name);
c.add(tfFather/Husband's Name);

c.add(lAge);
c.add(tfAge);

c.add(lAddress);
c.add(tfAddress);

c.add(lProvance);
c.add(tfProvance);

c.add(bSave);
c.add(bExit);

/*registering buttons with actionListner*/
bSave.addActionListener(this);
bExit.addActionListener(this);

myFrame.setSize(240,315);
myFrame.setResizable(false);
myFrame.setVisible(true);

} // end initGUI() method

//*****************************************************************************************
// implementing ActionListener's method i.e. actionPerformed()
public void actionPerformed (ActionEvent event )
{

/*if button bSave generates the event */
if (event.getSource () == bSave)
{
savePerson();

// clear fields
clear();
}



/*if button bExit generates the event */
else if (event.getSource() == bExit)
{
System.exit(0);
}

}// end actionPerformed

//********************************************************************************************************
// used to save person information into DB, using PersonDAO
public void savePerson()
{
/*get values from text fields*/
NIc Card = Integer.parseInt(tfNIC Card.getText());
Father/Husband's Name = tfFather/Husband's Name.getText();
Age = Integer.parseInt(tfAge.getText());
Address = tfAddress.getText();
Provance = tfProvance.getText();

if(NIC Card.equals(""))
{
JOptionPane.showMessageDialog(null, "Please enter NIC Card Number.");
}else
{

/*create a new PersonInfo object and pass it to PersonDAO to save it*/
PersonInfo person = new PersonInfo(NIC Card , father/Husband's Name, Age, address, Provance);
pDAO.savePerson(person);

JOptionPane.showMessageDialog(null, "Record added");
}
}// end GUI

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 66

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Replies to This Discussion

56 errors

RSS

Latest Activity

m.tahir joined + M.Tariq Malik's group
10 minutes ago
MUDASAR SHAKIL liked ♦_"Tooba"_♦'s photo
23 minutes ago
MUDASAR SHAKIL liked jiya's profile
24 minutes ago
Ikra butt posted a status
39 minutes ago
Ikra butt posted a status
"https://www.youtube.com/channel/UCVnIaKstaSmXBwF5-8rTGTw Its YOUTUBE CHANNEL for all solution GDB, ASSIGNMENTS, QUIZZ"
39 minutes ago
+ !♛EMAN FATIMA! joined + M.Tariq Malik's group
42 minutes ago
Shakir Siddiqui posted a status
"Design of FANETs as an Application of Remote Virtual Health Assistant"
43 minutes ago
Ikra butt joined + M.Tariq Malik's group
47 minutes ago
ϝ ι ყ α liked + ! ! ! ! ! ! ! ! ! ! ! ! ! ! !'s discussion Hamesha sath rehne ki aadat kuch nahin hoti
1 hour ago
+ Iuuoɔǝut + posted discussions
1 hour ago
+ ! ! ! ! ! ! ! ! ! AG replied to + "J ɨ y ą ⋆'s discussion Mohabat
1 hour ago
+ ! ! ! ! ! ! ! ! ! AG liked + "J ɨ y ą ⋆'s discussion Hona chahy tha.......
1 hour ago
+ ! ! ! ! ! ! ! ! ! AG liked + "J ɨ y ą ⋆'s discussion Mohabat
1 hour ago
Aqsa batool liked + M.Tariq Malik's discussion MTH202 Discrete Mathematics Assignment No 01 Fall 2019 Solution & Discussion
1 hour ago
Muhammad Azam liked + M.Tariq Malik's group MTH401 Differential Equations
1 hour ago
Mezab-E-Rehmat liked + Iuuoɔǝut +'s discussion ENG101-Midterm -MCQS- and Subjective Solved With-References By Moaaz 2011
1 hour ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion MTH631 - Real Analysis II Assignment No 01 Fall 2019 Solution & Discussion in the group MTH631 - Real Analysis II
1 hour ago
+ M.Tariq Malik liked + M.Tariq Malik's discussion MTH631 - Real Analysis II Assignment No 01 Fall 2019 Solution & Discussion
1 hour ago
+ M.Tariq Malik added a discussion to the group MTH631 - Real Analysis II
1 hour ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion PSY101 Introduction to Psychology Assignment No 01 Fall 2019 Solution & Discussion in the group PSY101 Introduction to Psychology
1 hour ago

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service