Essays24.com - Term Papers and Free Essays
Search

Pos 407 Week1

Essay by   •  November 17, 2010  •  765 Words (4 Pages)  •  1,202 Views

Essay Preview: Pos 407 Week1

Report this essay
Page 1 of 4

/**

This is the Week2 Mortgage calculator GUI box for POS 407, calculates loan, rate, and term.

*/

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Week2 implements ActionListener {

JFrame calculatorFrame;

JPanel calculatorPanel;

JTextField loan;

JTextField rate;

JTextField term;

JLabel loanLabel,termLabel, rateLabel, pmtLabel;

JButton calculate;

public Week2() {

if(readData()) {

calculatorFrame = new JFrame("Week 2 Mortgage Calculator");

calculatorFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

calculatorFrame.setBounds(0,0,100,100);

calculatorPanel = new JPanel(new GridLayout(10, 10));

addWidgets();

calculatorFrame.getRootPane().setDefaultButton(calculate);

calculatorFrame.getContentPane().add(calculatorPanel, BorderLayout.

CENTER);

calculatorFrame.pack();

calculatorFrame.setVisible(true);

}

}

private boolean readData() {

boolean isValid = true;

// we don't do anything, we will use this later

return isValid;

}

private void addWidgets() {

loan = new JTextField();

rate = new JTextField();

term = new JTextField();

loanLabel = new JLabel("Loan", SwingConstants.LEFT);

termLabel = new JLabel("Term", SwingConstants.LEFT);

rateLabel = new JLabel("Interest", SwingConstants.LEFT);

calculate = new JButton("Calculate");

pmtLabel = new JLabel("Monthly Payment", SwingConstants.LEFT);

calculate.addActionListener(this);

calculatorPanel.add(loan);

calculatorPanel.add(loanLabel);

calculatorPanel.add(term);

calculatorPanel.add(termLabel);

calculatorPanel.add(rate);

calculatorPanel.add(rateLabel);

calculatorPanel.add(calculate);

calculatorPanel.add(pmtLabel);

loanLabel.setBorder(BorderFactory.createEmptyBorder(9,9,9,9));

pmtLabel.setBorder(BorderFactory.createEmptyBorder(9,9,9,9));

}

public void actionPerformed(ActionEvent event) {

double tamount = 0;

int term1 = 0;

double rate1 = 0;

java.text.DecimalFormat dec = new java.text.DecimalFormat(",###.00");

boolean isValid = true;

String testit = loan.getText();

...

...

Download as:   txt (3.7 Kb)   pdf (74.9 Kb)   docx (10.2 Kb)  
Continue for 3 more pages »
Only available on Essays24.com