Link to home
Start Free TrialLog in
Avatar of PapaDragonX
PapaDragonX

asked on

Mortgage Calculator GUI

Good Evening,

I have the layout complete on my mortgage calculator but I cannot figure out why my program keeps on saying "reached end of file while parsing" when compiling AND why I cannot get it to calculate the numbers in the fields.  I am pretty sure I have it all in there but obviously I do not.  Any help would be great on these two issues.  Here is the code
 
// Importing Class
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.NumberFormat;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;


import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;

import java.text.DecimalFormat;   //For display the monthly payments as money




// Create Mortgage Payment Class
public class MortgageCalculator extends JFrame {

      static  String mortgage[] = {"Select Mortgage","10 years at 5.35%","20 years at 5.5%","30 years at 5.75%"};
      static String [] toReplace;
         DecimalFormat money = new DecimalFormat("$###,###.00");

   // Define the JPanel where we will draw and place all of our components.
    JPanel contentPanel = null;

    // GUI elements to display labels, fields, table, scoll pane for current information
    JLabel main_title = null;

    JLabel principal_label = null;
    JTextField principal_text = null;

    JLabel years_label = null;
    JTextField years_text = null;

    JLabel rate_label = null;
    JTextField rate_text = null;

    JLabel choose_label = null;
    JComboBox choose_combo = null;

    JRadioButton rbutton01 = null;
    JRadioButton rbutton02 = null;

    ButtonGroup buttongroup = null;

    //GUI text area for results with scroll pane
    JTextArea result = null;
    JScrollPane scrolling_result = null;

    //GUI for Table with scroll pane
    MyJTable total_amounts = null;
    JScrollPane scrolling_table = null;
    MyDTableModel model;

    // creates the button for calculation of the mortgage payments
    JButton btnCalculate = null;
    // Creates a button for reset button
    JButton btnReset = null;

     // Declaration of variables

        int numberOfLinesGenerated=1;
        double number_years; //term mortgage
        double principal; // amount borrowed
        double interest_rate;  // interest for mortgage
        double monthly_payment;  // monthly payment for mortgage
        double monthly_interest_rate ; // monthly interest
        double number_of_months; // number of months for mortgage payments
        double interest_paid; //interest amount added for each month
        double principal_paid;


     //This is the class constructor - initialize the components

    public MortgageCalculator() {
        super();
        initialize();
    }

    public void initialize() {
        // Defines the window size of 600px by 500 px
        this.setSize(700, 600);
        // The JPanel is where all the components are places.
        this.setContentPane(getJPanel());
        // Define the title of the window.
        this.setTitle("McBride Financial Services Mortgage Calculator");
    }

    public JPanel getJPanel() {
        if (contentPanel == null) {
            // initializes the contentPanel
            contentPanel = new JPanel();
            // Set the Panel to null to put the components into the panel
            contentPanel.setLayout(null);

            contentPanel.setBackground(new Color(38,44,125));

            // GUI elements to display labels and fields for current information

            // Main Title of the Calculator
            main_title = new JLabel();
            //This will center the label
            main_title.setHorizontalAlignment(SwingConstants.CENTER);
            // Set the boundary of this label
            main_title.setBounds(200, 20, 300, 30);
            // Sets the title to application
            main_title.setText("Mortgage Calculator");
            //sets the font size and font
            main_title.setFont(new Font("Serif", Font.PLAIN, 27));
           //sets the font color
            main_title.setForeground(Color.white);

            // Add the Title to the  contentPanel
            contentPanel.add(main_title);

            //Principal Label
            principal_label = new JLabel();
            //This will align the label right
            principal_label.setHorizontalAlignment(SwingConstants.RIGHT);
            // Set the boundary of this label
            principal_label.setBounds(90, 65, 220, 25);
            // Sets the label text
            principal_label.setText("Mortgage Principal : ");
            //sets the font size and font
            principal_label.setFont(new Font("Sans Serif", Font.BOLD, 14));
            //sets the font color
            principal_label.setForeground(Color.white);
            //Adds it to the contentPanel
            contentPanel.add(principal_label);

            //Principal Text Field
            principal_text = new JTextField();
            // Set the boundary of this text field
            principal_text.setBounds(350, 65, 160, 25);
            //sets what it entered in text field
            principal_text.setText(Double.toString(principal));
            //Adds it to the contentPanel
            contentPanel.add(principal_text);

             //Number of Years Label
            years_label = new JLabel();
            years_label.setHorizontalAlignment(SwingConstants.RIGHT);
            years_label.setBounds(90, 125, 220, 25);
            years_label.setText("Mortgage Term : ");
            years_label.setFont(new Font("Sans Serif", Font.BOLD, 14));
            years_label.setForeground(Color.white);
            contentPanel.add(years_label);

            //Number of Years Text Field
            years_text = new JTextField();
            years_text.setBounds(350, 125, 160, 25);
            years_text.setText(Double.toString(number_years));
            contentPanel.add(years_text);

            //Annual Interest Rate Label
            rate_label = new JLabel();
            rate_label.setHorizontalAlignment(SwingConstants.RIGHT);
            rate_label.setBounds(90, 165, 220, 25);
            rate_label.setText("Annunal Interest Rate : ");
            rate_label.setFont(new Font("Sans Serif", Font.BOLD, 14));
            rate_label.setForeground(Color.white);
            contentPanel.add(rate_label);

            //Annual Interest Rate  Text Field
            rate_text = new JTextField();
            rate_text.setBounds(350, 165, 160, 25);
            rate_text.setText(Double.toString(interest_rate * 100) + "%");
            contentPanel.add(rate_text);

           

            //Text Area for result
            result = new JTextArea(5, 20);
            result.setBounds(170, 250, 350, 75);
            scrolling_result = new JScrollPane(result);
            contentPanel.add(result);

            //Table for calculations
            total_amounts = new MyJTable();
            scrolling_table = new JScrollPane (total_amounts);
            scrolling_table.setBounds(20, 350, 650, 200);
            contentPanel.add(scrolling_table);


            // Creates a button for reset button
            btnReset = new JButton ();
            btnReset.setBounds(355, 200, 90, 30);
            btnReset.setText("Reset");
            contentPanel.add(btnReset);


            // creates the button for calculation of the mortgage payments
            btnCalculate = new JButton ();
            btnCalculate.setBounds(245, 200, 90, 30);
            btnCalculate.setText("Calculate");
            contentPanel.add(btnCalculate);




            // Adds the action listerner to  the reset button
            btnReset.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                // Calls the onButtonReset() method
                onButtonReset();
                 }
            });

           // This is the main area that when the calculate button is pressed,
            // will grab the values from the text fiedl and the combo box,
            // Calcutes the montly payment adds to result text area
            //and adds it to the table.
            btnCalculate.addActionListener(new ActionListener() {
                // Get the values for each of the field
                public void actionPerformed(ActionEvent e) {
                  principal=getDouble(principal_text.getText());
						interest_rate=getDouble(rate_text.getText());
						number_years=getDouble(years_text.getText());


                    {
                                    //calculates the number of months for mortgage
                    //This determines the number of payments to be made
                    number_of_months = number_years * 12;

                    //caluclates the monthly interest rate
                    monthly_interest_rate = interest_rate/12.0;

                    //Calculates the monthly payment for mortgage
                    monthly_payment = (principal* monthly_interest_rate)/(1 - Math.pow(1 + monthly_interest_rate, -number_of_months));


                   // Sets the result text
                    result.setText("Loan Amount = " + money.format(principal)
                    +"\nInterest Rate = " + (interest_rate * 100) +"%"+"\nLength of Loan = "
                    + Math.round(number_years * 12.0) + " months"+"\nMonthly Payment = "
                    + money.format(monthly_payment)); //calling the monthly_payment

                    // Have the necessary information for the model lets recalculate it.
                    if(total_amounts != null){
                        total_amounts.setModel(getModel());
                    }

                
            //Adds the calculate button
            contentPanel.add(btnCalculate);

            //Adds the scroll pane
            contentPanel.add(getScrollPane());
        }

        return contentPanel;
    }




    // This the Scroll pane for the table - sets the boundary
    public JScrollPane getScrollPane() {
        if (scrolling_table == null) {
            scrolling_table = new JScrollPane();
            scrolling_table.setBounds(65, 225, 425, 120);
            scrolling_table.setViewportView(getTable());
        }
        return scrolling_table;
    }

    public JTable getTable() {
        if (total_amounts == null) {
                total_amounts = new MyJTable(getModel());
        }
        return total_amounts;
    }

    //this will calculate the model for the table over and over again.
    public MyDTableModel getModel() {
        String[] columnNames = {"Payment Number", "Begin Balance", "Monthly Payment","Interest Paid","Principal Paid", "Ending Balance"};

        model = null;
        model = new MyDTableModel();
        for (int i = 0; i < 6; i++) {
            model.addColumn(columnNames[i]);
        }

        // This is the necessary data to calculate the table
        if (principal > 0 && interest_rate != 0 && number_years != 0) {
            double new_principal = principal;
            NumberFormat nf = NumberFormat.getCurrencyInstance();
            for (int i = 0; i < number_of_months; i++) {
                Object data[] = new Object[6];
                 data[0] = Integer.toString(i + 1);
                data[1] = nf.format(new_principal);
                data[2] = nf.format(monthly_payment);
                data[3] = nf.format(interest_paid = principal * monthly_interest_rate);
                data[4] = nf.format(principal_paid = monthly_payment - interest_paid);
                data[5] = nf.format(principal = principal - principal_paid);
                new_principal = principal;

                model.addRow(data);
            }
        }
        return model;
    }

    /**
     * The following will parse a double value from entered string
     * If the number is entered with a dollar sign, than parse it
     * one way otherwise parse it using the default number.
     * If there is an error, then zero will be returned
     * @return value
     */
    public double getDouble(String val) {
        double value = 00;
        try {
            // this tests to see if there is a dollar sign, if there
            // is it uses the currency number formater, otherwise just
            // the number formatter.
            if (val.indexOf('$') > -1) {
                // we need to use the currency expression
                value = NumberFormat.getCurrencyInstance().parse(val).doubleValue();
            } else {
                value = NumberFormat.getNumberInstance().parse(val).doubleValue();
            }
        } catch (java.text.ParseException e) {
            // Generates an error here, can add a JOptionDialog to display the
            // text and the error
            JOptionPane.showMessageDialog(this, "There is an error " + val + ". Please check your entry", "Data Entry Error", JOptionPane.ERROR_MESSAGE);
        }
        return value;
    }

    /**
     * The following will parse a string with a percent or no percent sign, and then divide it to decimal format.
     * @param val
     * @return
     */
    public double getPercent(String val) {
        boolean isPercent = false;
        double value = 0;
        try {
            if (val.indexOf('%') > -1) {
                value = NumberFormat.getPercentInstance().parse(val).doubleValue();
                isPercent = true;
            } else {
                value = NumberFormat.getNumberInstance().parse(val).doubleValue();
            }
        } catch (java.text.ParseException e) {
            JOptionPane.showMessageDialog(this, "There is an error " + val + ". Please check your entry", "Data Entry Error", JOptionPane.ERROR_MESSAGE);
        }

        // Have a percentage already in decimal format
        if(!isPercent)
            value = value/100.0;

        return value;
    }

      // Information for  Reset Button
         public void onButtonReset(){

        // Resets the fields
        principal_text.setText("");
        result.setText("");
        total_amounts.setModel(new MyDTableModel());

    }

    
    public static void main(String[] args) {
        
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                MortgageCalculator thisClass = new MortgageCalculator();
                thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                thisClass.setVisible(true);
					 }
					 }
					 }
               
    

   
 
		  

    

Open in new window

Avatar of for_yan
for_yan
Flag of United States of America image

You have some issue with the number of braces if reached end of file while parsing
Avatar of PapaDragonX
PapaDragonX

ASKER

I keep on trying different number of braces but get the same effect.  I thought I have the required amount.
Are you using any IDE?
This makse all the difference with braces
Yes I am.  Maybe I am missing something in one of the methods.
Use IDE only for the sake of braces if for nothing else.
And the key there when you tyoe in IDE make sure at every moment
(say, almost at every moment) IDE shoud be happy with the number of braces -
then you'll never (almost never) have any issues with braces
Avatar of Mick Barry
you aren't closing a few methods calls

try thuis

// Importing Class
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.NumberFormat;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;

import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;

import java.text.DecimalFormat; //For display the monthly payments as money

// Create Mortgage Payment Class
public class MortgageCalculator extends JFrame {

	static String mortgage[] = { "Select Mortgage", "10 years at 5.35%",
			"20 years at 5.5%", "30 years at 5.75%" };
	static String[] toReplace;
	DecimalFormat money = new DecimalFormat("$###,###.00");

	// Define the JPanel where we will draw and place all of our components.
	JPanel contentPanel = null;

	// GUI elements to display labels, fields, table, scoll pane for current
	// information
	JLabel main_title = null;

	JLabel principal_label = null;
	JTextField principal_text = null;

	JLabel years_label = null;
	JTextField years_text = null;

	JLabel rate_label = null;
	JTextField rate_text = null;

	JLabel choose_label = null;
	JComboBox choose_combo = null;

	JRadioButton rbutton01 = null;
	JRadioButton rbutton02 = null;

	ButtonGroup buttongroup = null;

	// GUI text area for results with scroll pane
	JTextArea result = null;
	JScrollPane scrolling_result = null;

	// GUI for Table with scroll pane
	MyJTable total_amounts = null;
	JScrollPane scrolling_table = null;
	MyDTableModel model;

	// creates the button for calculation of the mortgage payments
	JButton btnCalculate = null;
	// Creates a button for reset button
	JButton btnReset = null;

	// Declaration of variables

	int numberOfLinesGenerated = 1;
	double number_years; // term mortgage
	double principal; // amount borrowed
	double interest_rate; // interest for mortgage
	double monthly_payment; // monthly payment for mortgage
	double monthly_interest_rate; // monthly interest
	double number_of_months; // number of months for mortgage payments
	double interest_paid; // interest amount added for each month
	double principal_paid;

	// This is the class constructor - initialize the components

	public MortgageCalculator() {
		super();
		initialize();
	}

	public void initialize() {
		// Defines the window size of 600px by 500 px
		this.setSize(700, 600);
		// The JPanel is where all the components are places.
		this.setContentPane(getJPanel());
		// Define the title of the window.
		this.setTitle("McBride Financial Services Mortgage Calculator");
	}

	public JPanel getJPanel() {
		if (contentPanel == null) {
			// initializes the contentPanel
			contentPanel = new JPanel();
			// Set the Panel to null to put the components into the panel
			contentPanel.setLayout(null);

			contentPanel.setBackground(new Color(38, 44, 125));

			// GUI elements to display labels and fields for current information

			// Main Title of the Calculator
			main_title = new JLabel();
			// This will center the label
			main_title.setHorizontalAlignment(SwingConstants.CENTER);
			// Set the boundary of this label
			main_title.setBounds(200, 20, 300, 30);
			// Sets the title to application
			main_title.setText("Mortgage Calculator");
			// sets the font size and font
			main_title.setFont(new Font("Serif", Font.PLAIN, 27));
			// sets the font color
			main_title.setForeground(Color.white);

			// Add the Title to the contentPanel
			contentPanel.add(main_title);

			// Principal Label
			principal_label = new JLabel();
			// This will align the label right
			principal_label.setHorizontalAlignment(SwingConstants.RIGHT);
			// Set the boundary of this label
			principal_label.setBounds(90, 65, 220, 25);
			// Sets the label text
			principal_label.setText("Mortgage Principal : ");
			// sets the font size and font
			principal_label.setFont(new Font("Sans Serif", Font.BOLD, 14));
			// sets the font color
			principal_label.setForeground(Color.white);
			// Adds it to the contentPanel
			contentPanel.add(principal_label);

			// Principal Text Field
			principal_text = new JTextField();
			// Set the boundary of this text field
			principal_text.setBounds(350, 65, 160, 25);
			// sets what it entered in text field
			principal_text.setText(Double.toString(principal));
			// Adds it to the contentPanel
			contentPanel.add(principal_text);

			// Number of Years Label
			years_label = new JLabel();
			years_label.setHorizontalAlignment(SwingConstants.RIGHT);
			years_label.setBounds(90, 125, 220, 25);
			years_label.setText("Mortgage Term : ");
			years_label.setFont(new Font("Sans Serif", Font.BOLD, 14));
			years_label.setForeground(Color.white);
			contentPanel.add(years_label);

			// Number of Years Text Field
			years_text = new JTextField();
			years_text.setBounds(350, 125, 160, 25);
			years_text.setText(Double.toString(number_years));
			contentPanel.add(years_text);

			// Annual Interest Rate Label
			rate_label = new JLabel();
			rate_label.setHorizontalAlignment(SwingConstants.RIGHT);
			rate_label.setBounds(90, 165, 220, 25);
			rate_label.setText("Annunal Interest Rate : ");
			rate_label.setFont(new Font("Sans Serif", Font.BOLD, 14));
			rate_label.setForeground(Color.white);
			contentPanel.add(rate_label);

			// Annual Interest Rate Text Field
			rate_text = new JTextField();
			rate_text.setBounds(350, 165, 160, 25);
			rate_text.setText(Double.toString(interest_rate * 100) + "%");
			contentPanel.add(rate_text);

			// Text Area for result
			result = new JTextArea(5, 20);
			result.setBounds(170, 250, 350, 75);
			scrolling_result = new JScrollPane(result);
			contentPanel.add(result);

			// Table for calculations
			total_amounts = new MyJTable();
			scrolling_table = new JScrollPane(total_amounts);
			scrolling_table.setBounds(20, 350, 650, 200);
			contentPanel.add(scrolling_table);

			// Creates a button for reset button
			btnReset = new JButton();
			btnReset.setBounds(355, 200, 90, 30);
			btnReset.setText("Reset");
			contentPanel.add(btnReset);

			// creates the button for calculation of the mortgage payments
			btnCalculate = new JButton();
			btnCalculate.setBounds(245, 200, 90, 30);
			btnCalculate.setText("Calculate");
			contentPanel.add(btnCalculate);

			// Adds the action listerner to the reset button
			btnReset.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					// Calls the onButtonReset() method
					onButtonReset();
				}
			});

			// This is the main area that when the calculate button is pressed,
			// will grab the values from the text fiedl and the combo box,
			// Calcutes the montly payment adds to result text area
			// and adds it to the table.
			btnCalculate.addActionListener(new ActionListener() {
				// Get the values for each of the field
				public void actionPerformed(ActionEvent e) {
					principal = getDouble(principal_text.getText());
					interest_rate = getDouble(rate_text.getText());
					number_years = getDouble(years_text.getText());

					{
						// calculates the number of months for mortgage
						// This determines the number of payments to be made
						number_of_months = number_years * 12;

						// caluclates the monthly interest rate
						monthly_interest_rate = interest_rate / 12.0;

						// Calculates the monthly payment for mortgage
						monthly_payment = (principal * monthly_interest_rate)
								/ (1 - Math.pow(1 + monthly_interest_rate,
										-number_of_months));

						// Sets the result text
						result.setText("Loan Amount = "
								+ money.format(principal)
								+ "\nInterest Rate = " + (interest_rate * 100)
								+ "%" + "\nLength of Loan = "
								+ Math.round(number_years * 12.0) + " months"
								+ "\nMonthly Payment = "
								+ money.format(monthly_payment)); // calling the
																	// monthly_payment

						// Have the necessary information for the model lets
						// recalculate it.
						if (total_amounts != null) {
							total_amounts.setModel(getModel());
						}
					}
				}
			});
			// Adds the calculate button
			contentPanel.add(btnCalculate);

			// Adds the scroll pane
			contentPanel.add(getScrollPane());
		}

		return contentPanel;
	}

	// This the Scroll pane for the table - sets the boundary
	public JScrollPane getScrollPane() {
		if (scrolling_table == null) {
			scrolling_table = new JScrollPane();
			scrolling_table.setBounds(65, 225, 425, 120);
			scrolling_table.setViewportView(getTable());
		}
		return scrolling_table;
	}

	public JTable getTable() {
		if (total_amounts == null) {
			total_amounts = new MyJTable(getModel());
		}
		return total_amounts;
	}

	// this will calculate the model for the table over and over again.
	public MyDTableModel getModel() {
		String[] columnNames = { "Payment Number", "Begin Balance",
				"Monthly Payment", "Interest Paid", "Principal Paid",
				"Ending Balance" };

		model = null;
		model = new MyDTableModel();
		for (int i = 0; i < 6; i++) {
			model.addColumn(columnNames[i]);
		}

		// This is the necessary data to calculate the table
		if (principal > 0 && interest_rate != 0 && number_years != 0) {
			double new_principal = principal;
			NumberFormat nf = NumberFormat.getCurrencyInstance();
			for (int i = 0; i < number_of_months; i++) {
				Object data[] = new Object[6];
				data[0] = Integer.toString(i + 1);
				data[1] = nf.format(new_principal);
				data[2] = nf.format(monthly_payment);
				data[3] = nf.format(interest_paid = principal
						* monthly_interest_rate);
				data[4] = nf.format(principal_paid = monthly_payment
						- interest_paid);
				data[5] = nf.format(principal = principal - principal_paid);
				new_principal = principal;

				model.addRow(data);
			}
		}
		return model;
	}

	/**
	 * The following will parse a double value from entered string If the number
	 * is entered with a dollar sign, than parse it one way otherwise parse it
	 * using the default number. If there is an error, then zero will be
	 * returned
	 * 
	 * @return value
	 */
	public double getDouble(String val) {
		double value = 00;
		try {
			// this tests to see if there is a dollar sign, if there
			// is it uses the currency number formater, otherwise just
			// the number formatter.
			if (val.indexOf('$') > -1) {
				// we need to use the currency expression
				value = NumberFormat.getCurrencyInstance().parse(val)
						.doubleValue();
			} else {
				value = NumberFormat.getNumberInstance().parse(val)
						.doubleValue();
			}
		} catch (java.text.ParseException e) {
			// Generates an error here, can add a JOptionDialog to display the
			// text and the error
			JOptionPane.showMessageDialog(this, "There is an error " + val
					+ ". Please check your entry", "Data Entry Error",
					JOptionPane.ERROR_MESSAGE);
		}
		return value;
	}

	/**
	 * The following will parse a string with a percent or no percent sign, and
	 * then divide it to decimal format.
	 * 
	 * @param val
	 * @return
	 */
	public double getPercent(String val) {
		boolean isPercent = false;
		double value = 0;
		try {
			if (val.indexOf('%') > -1) {
				value = NumberFormat.getPercentInstance().parse(val)
						.doubleValue();
				isPercent = true;
			} else {
				value = NumberFormat.getNumberInstance().parse(val)
						.doubleValue();
			}
		} catch (java.text.ParseException e) {
			JOptionPane.showMessageDialog(this, "There is an error " + val
					+ ". Please check your entry", "Data Entry Error",
					JOptionPane.ERROR_MESSAGE);
		}

		// Have a percentage already in decimal format
		if (!isPercent)
			value = value / 100.0;

		return value;
	}

	// Information for Reset Button
	public void onButtonReset() {

		// Resets the fields
		principal_text.setText("");
		result.setText("");
		total_amounts.setModel(new MyDTableModel());

	}

	public static void main(String[] args) {

		SwingUtilities.invokeLater(new Runnable() {

			public void run() {
				MortgageCalculator thisClass = new MortgageCalculator();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
			}
		});
	}
}

Open in new window

Well, let's see in this case, but follow my advice in future - you'll indeed have much less time spent with braces.
Say you start   typeing "try{" it will immediately color everything so typ the closing
brace and in this case ive catch Exception parethesie and brace and then it becomes happy and you work
within created braces. the same with loops - if you follow that - it is much easier with braces
Thanks objects.  I see what happened here.  Now I have 7 different errors on compile
Well, while I was giving you advice, objects found the braces.
Nevertheless, I think I gave you good advice - with that and the ability to find the closing (or starting) brace in
the IDE corresponding to the slecetd brace - you'll not need to go to EE for fxing braces in future.
Here is the thing,  I switched from having a combo_box (JComboBox) to just having text fields for individual data entry.  But my code got all jumbled in that process and now I am not sure how to get it back.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks to you both.  I am back to the drawing board but I am sure I can come up with something.