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 myPrintButton;
|
||||||
private JButton myResetButton;
|
private JButton myResetButton;
|
||||||
private JLabel myResultBox;
|
private JLabel myResultBox;
|
||||||
|
private JTextField myNameField;
|
||||||
|
|
||||||
class ComboChoice
|
class ComboChoice
|
||||||
{
|
{
|
||||||
@ -70,8 +71,8 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
|||||||
inner.add(new JLabel("What is your name?", SwingConstants.RIGHT), c);
|
inner.add(new JLabel("What is your name?", SwingConstants.RIGHT), c);
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
c.weightx = 1.0;
|
c.weightx = 1.0;
|
||||||
field = new JTextField();
|
myNameField = new JTextField();
|
||||||
inner.add(field, c);
|
inner.add(myNameField, c);
|
||||||
c.gridx--;
|
c.gridx--;
|
||||||
c.gridy++;
|
c.gridy++;
|
||||||
|
|
||||||
@ -200,7 +201,12 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
|||||||
c.gridy++;
|
c.gridy++;
|
||||||
|
|
||||||
c.gridwidth = 2;
|
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);
|
inner.add(myResultBox, c);
|
||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
c.gridy++;
|
c.gridy++;
|
||||||
@ -244,7 +250,10 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
myModel.calculate();
|
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()
|
private void reset()
|
||||||
@ -283,6 +292,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
myNameField.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void print()
|
private void print()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user