473,473 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Not sure how too!!!

34 New Member
Not sure if I'm looking at it right. But I wrote a program that is going to display 3 different mortgages at once. But they all stream together, I'm trying to block them where each mortgage has its own area in my GUI window. Can someone point me in the right direction?
Mar 25 '07 #1
1 1080
ghostrider
34 New Member
Okay this is what I have. I'm trying to get my program to show 3 different mortgages neatly. An maybe throw in a menu prompt that you could chose which mortgage you would like to see first. Can anyone help me with that?


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java. text.*;

public class wk3_jrs extends JFrame implements ActionListener
{
JLabel amountLabel = new JLabel("Principle Loan");
JTextField amountField = new JTextField(7);
JLabel termLabel1 = new JLabel("Term of loan");
JTextField termField1 = new JTextField(4);
JLabel interestLabel1 = new JLabel("Interest Rate");
JTextField interestField1 = new JTextField(5);
JTextField paymentField1 = new JTextField(9);
JLabel termLabel2 = new JLabel("Term of loan");
JTextField termField2 = new JTextField(4);
JLabel interestLabel2 = new JLabel("Interest Rate");
JTextField interestField2 = new JTextField(5);
JTextField paymentField2 = new JTextField(9);
JLabel termLabel3 = new JLabel("Term of loan");
JTextField termField3 = new JTextField(4);
JLabel interestLabel3 = new JLabel("Interest Rate");
JTextField interestField3 = new JTextField(5);
JTextField paymentField3 = new JTextField(9);
JButton calculate = new JButton("Calculate Payment");
JButton myButton = new JButton("Clear");
JButton myButton1 = new JButton("Exit");

public wk3_jrs()
{
super("Joe's Mortgage Calculator");
setSize(700, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
Container pane = getContentPane();

FlowLayout layout = new FlowLayout();

pane.add(amountLabel);
pane.add(amountField);
pane.add(termLabel1);
pane.add(termField1);
pane.add(interestLabel1);
pane.add(interestField1);
pane.add(paymentField1);
System.out.println ("\n");
pane.add(termLabel2);
pane.add(termField2);
pane.add(interestLabel2);
pane.add(interestField2);
pane.add(paymentField2);
System.out.println ("\n");
pane.add(termLabel3);
pane.add(termField3);
pane.add(interestLabel3);
pane.add(interestField3);
pane.add(paymentField3);
pane.add(calculate);
pane.add(myButton);
pane.add(myButton1);
pane.add(myButton);
pane.add(myButton1);

pane.setLayout(layout);
setContentPane(pane);
pane.setBackground(Color.red);


amountField.addActionListener(this);
termField1.addActionListener(this);
interestField1.addActionListener(this);
paymentField1.addActionListener(this);
termField2.addActionListener(this);
interestField2.addActionListener(this);
paymentField2.addActionListener(this);
termField3.addActionListener(this);
interestField3.addActionListener(this);
paymentField3.addActionListener(this);
calculate.addActionListener(this);
myButton.addActionListener(this);
myButton1.addActionListener(this);

}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();

if(source == calculate)

{
double a = 200000;
double[] t = {30, 15, 7};
double[] i = {0.0575, 0.0550, 0.0575};
double payment1, payment2, payment3;

payment1 = (a*(i[0]/12)/(1-Math.pow(1+i[0], -t[0]*12)));
payment2 = (a*(i[1]/12)/(1-Math.pow(1+i[1], -t[1]*12)));
payment3 = (a*(i[2]/12)/(1-Math.pow(1+i[2], -t[2]*12)));
DecimalFormat decimalpoint = new DecimalFormat("0,000.00");

paymentField1.setText("$ "+decimalpoint.format (payment1));
paymentField2.setText("$ "+decimalpoint.format (payment2));
paymentField3.setText("$ "+decimalpoint.format (payment3));
}
if(source == myButton)
{
amountField.setText(null);
termField1.setText(null);
interestField1.setText(null);
paymentField1.setText(null);
termField2.setText(null);
interestField2.setText(null);
paymentField2.setText(null);
termField3.setText(null);
interestField3.setText(null);
paymentField3.setText(null);
}

if(source == myButton1)
{
System.exit(0);
}
}
public static void main(String[]args)
{
wk3_jrs calc = new wk3_jrs();
}
}
Mar 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
5
by: Pablo | last post by:
When I query or browse databases or tables in SQL Server 2000 it works extremely slow. It started working like this from one day to another. I tried reinstalling but it stayed the same. Now...
1
by: Gregory.Spencer | last post by:
Hi There, Been working in a PHP / MySQL project I took over code development for. Today when testing new changes suddenly started getting "Failed to connect to the database" errors. When...
2
by: Susan Bricker | last post by:
Greetings Experts ... I have a routine that is invoked when a command button is clicked. The button is located in a form that is tied to a table of Project records. Each Project Record has 0 to...
2
by: JA | last post by:
Why do I sometimes get the error "the text is too long to be edited" when trying to work directly in a memo field in Access 2000? Is there a way to make that go away? Thanks, JA
11
by: MLH | last post by:
If this is what MySQL is set to... SELECT DISTINCTROW qryVehiclesNowners5.SerialNum, qryVehiclesNowners5.VDescr, qryVehiclesNowners5.Owner, qryVehiclesNowners5.VehicleJobID ,...
11
by: George | last post by:
Was my question too challenging for everyone? I thought I would get a much quicker response, complete with witty and (sometimes) condescending remarks Here's my question again, in case you missed...
2
by: Seth | last post by:
Ok, here is my setup. I have a fully functioning HTTP Handler implemented. The handler is supposed to handle every single request that comes in to a particular virtual directory. Thus, in IIS, I...
39
by: slogging_away | last post by:
Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32, and have a script that makes numerous checks on text files, (configuration files), so discrepancies can be reported. The script...
2
by: John Oliver | last post by:
Fedora Core 2, httpd-2.0.54-10.2, php-4.3.10-2.4, postgresql-7.4.7-3.FC2.1 Using a test.php that includes: <?php pg_connect("host=localhost dbname=db_name user=user password=password$");...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.