Inner Classes, GUI’s, and a loan generator app.

In my attempt to learn as many things as possible this summer to become more employable I am trying to create an app that figures out the total months it would take to pay off a debt or loan given the premium, interest rate, and monthly payment.  I came to this idea because I think it would be a good tool for those that are budgeting like myself and it would be a great way to learn a few things in programming and get more practice.

So I am going to post my progress every Monday.  Right now I have built a template for the inner class build that I am using for the TextFields I am using.  I am going to have to spend this week trying to find a way to store the types of debt (debtName) and how to use the submit button to calculate the total months and have it displayed in a text field.

package DebtManager;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;

public class Practice extends JFrame{

//button member declaration needed here

JTextField textField = new JTextField();
JButton button1 = new JButton();

class Handler implements ActionListener

float b;

public void actionPerformed(ActionEvent e) {

String a;

try {
if (textField.getText().isEmpty()){
throw new Exception();

a = textField.getText();
b = Float.parseFloat(a);
catch (Exception e1){
System.out.println(b + ” field Left Blank”);


//Define an inner member class for each Text Field
protected void buildGUI()

//initialize the text fields

JTextField debtName = new JTextField(10);
JTextField TOwed = new javax.swing.JTextField();
JTextField interest = new javax.swing.JTextField();
JTextField monthly = new javax.swing.JTextField();

//Submit button needs method to do math, and send result to totalMonths
JButton submit = new javax.swing.JButton();

JTextField totalMonths = new javax.swing.JTextField();

//register inner class action listener for each button

//need separate method for debtName to just keep name as String
debtName.addActionListener(new Handler());

TOwed.addActionListener(new Handler());
interest.addActionListener(new Handler());
monthly.addActionListener(new Handler());

//need a separate method in handler for this.
totalMonths.addActionListener(new Handler());




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s