- /**
- * @(#)AccountPanel.java
- *
- *
- * @author
- * @version 1.00 2009/4/13
- */
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class AccountPanel extends JPanel
- {
- private JLabel startbalanceLabel, contribLabel, interestLabel, retireLabel, endingBalanceLabel;
- private JTextField sbalance, contrib, retire, interest;
- private JButton calculate;
- // constructor: sets up main gui components..
- public AccountPanel()
- {
- startbalanceLabel = new JLabel ("Enter starting balance: ");
- retireLabel = new JLabel ("how many years till retirement? ");
- contribLabel = new JLabel ("Yearly Contribution: ");
- interestLabel = new JLabel ("percent of interest: ");
- endingBalanceLabel = new JLabel ("------");
- sbalance = new JTextField (5);
- contrib = new JTextField (5);
- retire = new JTextField (2);
- interest = new JTextField (3);
- calculate = new JButton ("Calculate");
- calculate.addActionListener(new ButtonListener());
- add (startbalanceLabel);
- add (contribLabel);
- add (retireLabel);
- add (interestLabel);
- add (sbalance);
- add (contrib);
- add (retire);
- add (interest);
- add (calculate);
- add (endingBalanceLabel);
- setPreferredSize (new Dimension(400,100));
- }
- private class ButtonListener extends RetirementCalculator implements ActionListener
- {
- public void actionPerformed (ActionEvent event)
- {
- int startingBalance2, contribAdded2, retirement2;
- double interestEarned2, answer;
- String textbalance = sbalance.getText();
- String textcontrib = contrib.getText();
- String textinterest = interest.getText();
- String textretire = contrib.getText();
- startingBalance2 = Integer.parseInt (textbalance);
- contribAdded2 = Integer.parseInt (textcontrib);
- interestEarned2 = Double.parseDouble (textinterest);
- retirement2 = Integer.parseInt(textretire);
- AccountInformation[] values = retirementCalc( startingBalance2, contribAdded2, retirement2, interestEarned2);
- for(int i=0; i<values.length; i++)
- {
- System.out.println(values[i]);
- }
- System.out.println("Debugging endBalance:"+ getEndBalance());
- System.out.println("Debugging contribution:" + getContribution());
- System.out.println("Debugging interest:" + getInterestEarned());
- answer = getEndBalance();
- endingBalanceLabel.setText(Double.toString(answer));
- }
- }
- }
accountpanel
By: microhaxo | Date: Apr 13 2009 16:06 | Format: None | Expires: never | Size: 2.47 KB | Hits: 1021
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago