formatting result much more nicely
git-svn-id: svn://anubis/gvsu@447 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
1bbc1a7c6e
commit
46b24609a4
@ -20,6 +20,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
||||
private JButton myPrintButton;
|
||||
private JButton myResetButton;
|
||||
private JLabel myResultBox;
|
||||
private JTextField myNameField;
|
||||
|
||||
class ComboChoice
|
||||
{
|
||||
@ -70,8 +71,8 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
||||
inner.add(new JLabel("What is your name?", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
c.weightx = 1.0;
|
||||
field = new JTextField();
|
||||
inner.add(field, c);
|
||||
myNameField = new JTextField();
|
||||
inner.add(myNameField, c);
|
||||
c.gridx--;
|
||||
c.gridy++;
|
||||
|
||||
@ -200,7 +201,12 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
||||
c.gridy++;
|
||||
|
||||
c.gridwidth = 2;
|
||||
myResultBox = new JLabel(" ");
|
||||
inner.add(makeDivider(), c);
|
||||
c.gridwidth = 1;
|
||||
c.gridy++;
|
||||
|
||||
c.gridwidth = 2;
|
||||
myResultBox = new JLabel(" ", SwingConstants.CENTER);
|
||||
inner.add(myResultBox, c);
|
||||
c.gridwidth = 1;
|
||||
c.gridy++;
|
||||
@ -244,7 +250,10 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
||||
}
|
||||
|
||||
myModel.calculate();
|
||||
myResultBox.setText("The total amount of savings needed at retirement is $" + myModel.getField("total additional savings needed") + ". The annual amount of savings needed is $" + myModel.getField("annual savings needed"));
|
||||
myResultBox.setText("<html>The total amount of savings needed at retirement is $" +
|
||||
String.format("%,.02f", myModel.getField("total additional savings needed")) +
|
||||
".<br/> The annual amount of savings needed is $" +
|
||||
String.format("%,.02f", myModel.getField("annual savings needed")) + "</html>");
|
||||
}
|
||||
|
||||
private void reset()
|
||||
@ -283,6 +292,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
||||
}
|
||||
}
|
||||
}
|
||||
myNameField.setText("");
|
||||
}
|
||||
|
||||
private void print()
|
||||
|
Loading…
x
Reference in New Issue
Block a user