1 Replies - 1025 Views - Last Post: 21 March 2011 - 02:30 AM Rate Topic: -----

#1 TheMightyElk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-July 09

i need help with my mortgage calculator logic..

Posted 20 March 2011 - 11:55 PM

OK, so basically i used netbeans to create the Gui since i tried doing it from scratch and failed miserably. the gui used to load but i noticed the drop down box wasn't doing anything so i tried to assign it a value for each drop down then link that value to a math algeritm and now nothing works and i am lost.. im not a very fast learner and i am going to school online which means i have a week per assignment and its just not enough time.. if someone can look at this and help me out or show me what needs to go where. it is so irritating since i know how it has to work i just cant figure out the syntax. its like knowing what someone is saying yet not being able to speak their language...

/**
 *
 * @author Paul -this part prints money :-)-
 * CR5
 */

import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import java.text.DecimalFormat;




public class MortgageCalccr5 extends javax.swing.JFrame {
        DecimalFormat c = new DecimalFormat("$,###,###,###.00");

   
    public MortgageCalccr5() {
        initComponents();
        principal.setText(null);
       
       
       
    }


    

    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        titlelabel = new javax.swing.JLabel();
        loanamountlabel = new javax.swing.JLabel();
        loanoptionslsabel = new javax.swing.JLabel();
        calculate = new javax.swing.JButton();
        clear = new javax.swing.JButton();
        end = new javax.swing.JButton();
        payment = new javax.swing.JLabel();
        pmtField = new javax.swing.JLabel();
        principal = new javax.swing.JTextField();
        loanOption = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();

        jLabel1.setText("jLabel1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        
        titlelabel.setText("Payment calculator");
        loanamountlabel.setText("Principal Amount: $");
        loanoptionslsabel.setText("please select term and rates:");

        calculate.setText("Calculate");
        calculate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                calculateActionPerformed(evt);
            }
        });

        clear.setText("Clear");
        clear.setActionCommand("clear");
        clear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearActionPerformed(evt);
            }
        });

        end.setText("End Program");
        end.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endprogramActionPerformed(evt);
            }
        });

        payment.setText("Your Monthly  Payment Under This Loan is:  $");

        pmtField.setText("payment");

        principal.setText("principal");

        loanOption.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "7 years at 5.35%", "15 years at 5.5%", "30 years at 5.75%", " " }));
        loanOption.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	String.setSelectedIndex(2);
                loanOptionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(110, 110, 110)
                .addComponent(titlelabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(127, 127, 127))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(loanamountlabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(principal, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(108, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(loanoptionslsabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(loanOption, 0, 116, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(calculate)
                        .addGap(33, 33, 33)
                        .addComponent(clear)
                        .addGap(36, 36, 36)
                        .addComponent(end))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(payment)
                        .addGap(18, 18, 18)
                        .addComponent(pmtField)))
                .addContainerGap(74, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {calculate, clear});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlelabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(loanamountlabel)
                    .addComponent(principal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(loanoptionslsabel)
                    .addComponent(loanOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(calculate)
                    .addComponent(clear)
                    .addComponent(end))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(payment)
                    .addComponent(pmtField))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }

    	//* Does the calculations for the input provided
    private void calculateActionPerformed(java.awt.event.ActionEvent evt) {                                          
 		//* 7 years at 5.35%
    	if (loanOption = opt1);{
    		
    	}
    	
    	    //* 15 years at 5.5%
    	if (loanOption = opt2);{
    	
    	}
    	
    	//* 30 years at 5.75%
    	if (loanOption = opt3);{
    		 	Math.pow / (principal, 360);
    	}

    }    
    

    	//* Clears the input and printout fields
    private void clearActionPerformed(java.awt.event.ActionEvent evt) {                                      
        principal.setText(null);
        pmtField.setText(null);
     
    }                                    
    	//* Exits the program 
    private void endprogramActionPerformed(java.awt.event.ActionEvent evt) {                                          
        System.exit(0);
    }                                          

    private void loanOptionActionPerformed(java.awt.event.ActionEvent evt) {
    	
    		
   
    }

   
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MortgageCalccr5().setVisible(true);
            }
        });
    }


    private javax.swing.JButton calculate;
    private javax.swing.JButton clear;
    private javax.swing.JButton end;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JComboBox loanOption;
    private javax.swing.JLabel loanamountlabel;
    private javax.swing.JTextField principal;
    private javax.swing.JLabel loanoptionslsabel;
    private javax.swing.JLabel pmtField;
    private javax.swing.JLabel payment;
    private javax.swing.JLabel titlelabel;


}



Is This A Good Question/Topic? 0
  • +

Replies To: i need help with my mortgage calculator logic..

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: i need help with my mortgage calculator logic..

Posted 21 March 2011 - 02:30 AM

I am really sorry to tell you this, but if you are using the GUI Generator, you will find it hard to get help here simply because very few people can read the code that is generated. Sure, it is good for visualizing GUIs, but for the final product, you should always hand-code them. Swing is not that difficult to get started with and there are tons of resources available to help you.

DIC Swing Tutorials:
http://www.dreaminco...g-swing-part-i/
http://www.dreaminco...torial-part-ii/
http://www.dreaminco...orial-part-iii/
http://www.dreaminco...torial-part-iv/
http://www.dreaminco...ing-tutorial-v/

Oracle tutorials:
http://download.orac...wing/index.html
http://download.orac...l/ui/index.html

If you can narrow down your issue in the code you provided, we can *try* to help, but honestly, it is a better practice to hand code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1