/* This class contains the User Interface that Earnest Bank uses to add new loan types to the database. Whenever a new loan type is added, a property change event is generated */ importjava.awt.*; importjava.awt.event.*; importjava.io.Serializable; importjavax.swing.*; importjava.beans.*; publicclass Loan extendsJPanelimplementsActionListener { protectedPropertyChangeSupport changes=newPropertyChangeSupport(this); privateString loanType=newString("Personal Loan"); publicvoid setLoanType(String temp) { String old=newString(); old=loanType; loanType=temp; changes.firePropertyChange("loanType",old,temp); } publicString getLoanType() { return loanType; } JLabel lid,ltype; JTextField tid,ttype; JButtonsubmit; public Loan() { lid=newJLabel("Enter Loan Id:"); tid=newJTextField(8); ltype=newJLabel("Loan Type:"); ttype=newJTextField(15); submit=newJButton("ADD NEW LOAN"); setLayout(newGridLayout(3,2)); add(lid);add(tid); add(ltype);add(ttype); submit.addActionListener(this); add(submit); } publicvoidactionPerformed(ActionEvent evt) { Object obj=evt.getSource(); if(obj==submit) setLoanType(ttype.getText()); } publicvoidaddPropertyChangeListener(PropertyChangeListener l) { changes.addPropertyChangeListener(l); } publicvoidremovePropertyChangeListener(PropertyChangeListener l) { changes.removePropertyChangeListener(l); } }
//CustomerLoan.java
/* The following class is used by Earnest Bank to accept the details of customers who take loans. Whenever a new loan type is added to the database, the loan type should be made available to the user. /* This class traps the property change event generated by the Loan class and adds the new loan type to its loan type combo box. */