Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objective: The objective of this project is to practice using files of objects a

ID: 3576359 • Letter: O

Question

Objective: The objective of this project is to practice using files of objects and gain more experiences in developing interactive GUI using Java Swing and AWT toolkits.
Project description:
In this assignment, you are to design a Java program called address book to maintain a binary file of contacts. A contact record in the file should include the following information:
. First Name, a string of characters
. Last Name, a string of characters
. Email address, a string of characters
. Address, a string of characters
. Phone number, a string of characters
Your program should allow it’s user to do the following:
1. Create an address book.
2. Add contacts
3. Search contacts (optional)
4. Sort contacts (optional)
5. View/Delete contacts
6. Load contacts
7. Backup contacts
User interface requirement:
Your program should have a GUI closely similar to the following.

To submit your project:
1. A hardcopy of your Java source code.
2. Email a softcopy of your source code.
3. Demo your program on Athena before 12/08/2016
Programming hints about JLabel, JTable and JScrollPane:
1. To change the font size of a JLabel.
new JLabel(“

JLabel text

”);
2. Create a JScrollPane and add it to the center of the contentPane of a frame.
scrollPane = new JScrollPane();
contentPane.add(scrollPane,BorderLayout.CENTER);
3. Before display contacts.
a. Create a JTable.
JTable abtable = new JTable(data,columnName);
b. Use the JTable to create a temporary JScrollPane.
JScrollPane tmp = new JScrollPane(abtable);
c. Get the viewport from the temporary JScrollPane and add it to the original JScrollPane.
scrollPane.setViewport(tmp.getViewport

please help with the solution

GUI

Explanation / Answer

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class GuiAccTest extends Frame implements ActionListener
{
Label lab=new Label(" ");
Label lab1=new Label(" ");
TextField t[]=new TextField [4];
Label l[]=new Label [4];
Button but=new Button("Create Account");
Button but1=new Button("Test Account");
BankAccount b;
GuiAccTest()
{
addWindowListener(new NewWindowAdapter());
setLayout(new GridLayout(2,0));
Panel p=new Panel();
Panel p1=new Panel();
but.addActionListener(this);
but1.addActionListener(this);
p.setLayout(new GridLayout(5,2));
p1.add(lab1);
p1.add(lab);
l[0]=new Label("Account Number");
l[1]=new Label("Initial Balance");
l[2]=new Label("Deposit Amount");
l[3]=new Label("Withdraw Amount");
for(int i=0;i<4;i++)
{
t[i]=new TextField(10);
p.add(l[i]);
p.add(t[i]);
}
p.add(but);
p.add(but1);
but1.setVisible(false);
l[2].setVisible(false);
l[3].setVisible(false);
t[2].setVisible(false);
t[3].setVisible(false);
add(p);
add(p1);
}
String testAccount(int d_amt,int w_amt)
{
String msg;
b.deposit(d_amt);
msg="Transaction Succesful";
try
{
b.withdraw(w_amt);
}catch(FundsInsufficientException fe)
{
fe=new
FundsInsufficientException(b.amount,w_amt);
msg=String.valueOf(fe);
}
return msg;
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if(str.equals("Create Account"))
{
b=new
BankAccount(Integer.parseInt(t[0].getText()),
Integer.parseInt(t[1].getText()));
but1.setVisible(true);
l[2].setVisible(true);
l[3].setVisible(true);
t[2].setVisible(true);