added three buttons (but they do not do anything yet)

git-svn-id: svn://anubis/gvsu@439 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2009-10-04 21:42:04 +00:00
parent 9f5cc1a9ef
commit 3ee89f1571

View File

@ -13,13 +13,16 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
{
private RetirementCalculatorModel myModel;
protected JComponent makeDivider() { return new JLabel(" "); }
private JComponent makeDivider() { return new JLabel(" "); }
private HashMap<String, JComponent> myFields;
public RetirementCalculatorPanel()
{
super(new BorderLayout());
myFields = new HashMap<String, JComponent>();
JPanel inner = new JPanel(new GridBagLayout());
// inner.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
class ComboChoice
{
private String myDesc;
@ -41,12 +44,21 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
c.gridx = 0;
c.gridy = 0;
c.weightx = 0.0;
inner.add(new JLabel("What is your name?", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1.0;
field = new JTextField();
inner.add(field, c);
c.gridx--;
c.gridy++;
c.weightx = 0.0;
inner.add(new JLabel("How much annual income will you want in retirement?", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1.0;
field = new JTextField();
field.setMinimumSize(new Dimension(1, 1));
myFields.put("income wanted", field);
inner.add(field, c);
c.gridx--;
c.gridy++;
@ -56,6 +68,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
c.gridx++;
c.weightx = 1.0;
field = new JTextField();
myFields.put("current income", field);
inner.add(field, c);
c.gridx--;
c.gridy++;
@ -72,6 +85,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
c.gridx++;
c.weightx = 1.0;
field = new JTextField();
myFields.put("employer pension", field);
inner.add(field, c);
c.gridx--;
c.gridy++;
@ -81,6 +95,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
c.gridx++;
c.weightx = 1.0;
field = new JTextField();
myFields.put("part time income", field);
inner.add(field, c);
c.gridx--;
c.gridy++;
@ -90,6 +105,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
c.gridx++;
c.weightx = 1.0;
field = new JTextField();
myFields.put("other income", field);
inner.add(field, c);
c.gridx--;
c.gridy++;
@ -99,6 +115,16 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
c.gridwidth = 1;
c.gridy++;
c.weightx = 0.0;
inner.add(new JLabel("How much savings do you have to date?", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1.0;
field = new JTextField();
myFields.put("savings", field);
inner.add(field, c);
c.gridx--;
c.gridy++;
c.weightx = 0.0;
inner.add(new JLabel("At what age do you expect to retire?", SwingConstants.RIGHT), c);
c.gridx++;
@ -110,6 +136,7 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
new ComboChoice(70, "70")
};
field = new JComboBox(retirement_age_choices);
myFields.put("retirement age", field);
inner.add(field, c);
c.gridx--;
c.gridy++;
@ -126,12 +153,35 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
new ComboChoice(97, "97 (Female; 90th percentile)")
};
field = new JComboBox(life_expectancy_choices);
myFields.put("life expectancy", field);
p.add(field, BorderLayout.EAST);
c.gridwidth = 2;
inner.add(p, c);
c.gridwidth = 1;
c.gridy++;
c.gridwidth = 2;
inner.add(makeDivider(), c);
c.gridwidth = 1;
c.gridy++;
JPanel buttons = new JPanel();
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
buttons.add(Box.createHorizontalGlue());
JButton button = new JButton("Calculate");
buttons.add(button);
button = new JButton("Print");
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(button);
button = new JButton("Reset");
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(button);
buttons.add(Box.createHorizontalGlue());
c.gridwidth = 2;
inner.add(buttons, c);
c.gridwidth = 1;
c.gridy++;
JScrollPane scrollpane = new JScrollPane(inner,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);