diff --git a/cs623/proj1/RetirementCalculator.java b/cs623/proj1/RetirementCalculator.java index 26db56c..f0998f5 100644 --- a/cs623/proj1/RetirementCalculator.java +++ b/cs623/proj1/RetirementCalculator.java @@ -20,6 +20,18 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener super(new BorderLayout()); JPanel inner = new JPanel(new GridBagLayout()); // inner.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + class ComboChoice + { + private String myDesc; + private int myVal; + ComboChoice(int val, String desc) + { + myDesc = desc; + myVal = val; + } + public String toString() { return myDesc; } + public int getVal() { return myVal; } + } JComponent field; GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; @@ -91,7 +103,12 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener inner.add(new JLabel("At what age do you expect to retire?", SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1.0; - Integer[] retirement_age_choices = { 55, 60, 65, 70 }; + ComboChoice[] retirement_age_choices = { + new ComboChoice(55, "55"), + new ComboChoice(60, "60"), + new ComboChoice(65, "65"), + new ComboChoice(70, "70") + }; field = new JComboBox(retirement_age_choices); inner.add(field, c); c.gridx--; @@ -100,15 +117,15 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener JPanel p = new JPanel(new BorderLayout()); p.setAlignmentX(Component.RIGHT_ALIGNMENT); p.add(new JLabel("What is your life expectancy?", SwingConstants.RIGHT), BorderLayout.CENTER); - String[] choices = { - "82 (Male; 50th percentile)", - "86 (Female; 50th percentile)", - "89 (Male; 75th percentile)", - "92 (Female; 75th percentile)", - "94 (Male; 90th percentile)", - "97 (Female; 90th percentile)" + ComboChoice[] life_expectancy_choices = { + new ComboChoice(82, "82 (Male; 50th percentile)"), + new ComboChoice(86, "86 (Female; 50th percentile)"), + new ComboChoice(89, "89 (Male; 75th percentile)"), + new ComboChoice(92, "92 (Female; 75th percentile)"), + new ComboChoice(94, "94 (Male; 90th percentile)"), + new ComboChoice(97, "97 (Female; 90th percentile)") }; - field = new JComboBox(choices); + field = new JComboBox(life_expectancy_choices); p.add(field, BorderLayout.EAST); c.gridwidth = 2; inner.add(p, c);