implemented print() method with a dialog box
git-svn-id: svn://anubis/gvsu@449 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
c11c661054
commit
57670b1ad6
@ -311,9 +311,44 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
||||
myResultBox.setText(" ");
|
||||
}
|
||||
|
||||
private String fmt(String fmt, String field)
|
||||
{
|
||||
return String.format(fmt, myModel.getField(field));
|
||||
}
|
||||
|
||||
private void print()
|
||||
{
|
||||
calculate();
|
||||
String endl = "<br/>";
|
||||
String msg = "<html>";
|
||||
msg += "Name: " + myNameField.getText() + endl;
|
||||
msg += "Current income: $" + fmt("%.02f", "current income") + endl;
|
||||
msg += "Desired annual income: $" +
|
||||
fmt("%.02f", "income wanted") + endl;
|
||||
msg += endl;
|
||||
msg += "Social Security benefit: $" +
|
||||
fmt("%.02f", "social security") + endl;
|
||||
msg += "Traditional Employer Pension: $" +
|
||||
fmt("%.02f", "employer pension") + endl;
|
||||
msg += "Part-time income: $" + fmt("%.02f", "part time income") + endl;
|
||||
msg += "Other income: $" + fmt("%.02f", "other income") + endl;
|
||||
msg += "Amount to make up each retirement year: $" +
|
||||
fmt("%.02f", "amount to make up") + endl;
|
||||
msg += endl;
|
||||
msg += "Total amount to save: $" +
|
||||
fmt("%.02f", "amount to save") + endl;
|
||||
msg += "Early retirement addition: $" +
|
||||
fmt("%.02f", "early retirement penalty") + endl;
|
||||
msg += "Estimated savings at retirement: $" +
|
||||
fmt("%.02f", "estimated savings") + endl;
|
||||
msg += endl;
|
||||
msg += "Total additional savings needed at retirement: $" +
|
||||
fmt("%.02f", "total additional savings needed") + endl;
|
||||
msg += "Required annual savings: $" +
|
||||
fmt("%.02f", "annual savings needed") + endl;
|
||||
msg += "</html>";
|
||||
JOptionPane.showMessageDialog(null, msg,
|
||||
"Basic Retirement Calculator", JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user