added a bunch of fields
git-svn-id: svn://anubis/gvsu@436 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
8800104844
commit
7a2e468191
@ -1,11 +1,14 @@
|
|||||||
|
|
||||||
MAINCLASS := RetirementCalculator
|
MAINCLASS := RetirementCalculator
|
||||||
|
CLASSES := $(patsubst %.java,%.class,$(wildcard *.java))
|
||||||
|
|
||||||
all:
|
all: $(CLASSES)
|
||||||
javac *.java
|
|
||||||
|
%.class: %.java
|
||||||
|
javac $^
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run:
|
run: $(CLASSES)
|
||||||
java $(MAINCLASS)
|
java $(MAINCLASS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -13,34 +13,98 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
|||||||
{
|
{
|
||||||
private RetirementCalculatorModel myModel;
|
private RetirementCalculatorModel myModel;
|
||||||
|
|
||||||
private HashMap<String, Field> myFields;
|
|
||||||
|
|
||||||
public class Field extends JTextField
|
|
||||||
{
|
|
||||||
private String myName;
|
|
||||||
|
|
||||||
public Field(String name, String dflt)
|
|
||||||
{
|
|
||||||
super(dflt);
|
|
||||||
myName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() { return myName; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addField(JPanel addto, String caption, String name, String dflt)
|
|
||||||
{
|
|
||||||
addto.add(new JLabel(caption));
|
|
||||||
Field field = new Field(name, dflt);
|
|
||||||
myFields.put(name, field);
|
|
||||||
addto.add(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RetirementCalculatorPanel()
|
public RetirementCalculatorPanel()
|
||||||
{
|
{
|
||||||
JPanel inner = new JPanel(new GridLayout(3, 2));
|
super(new BorderLayout());
|
||||||
inner.add(new JLabel("How much annual income will you want in retirement?"));
|
JPanel inner = new JPanel(new GridBagLayout());
|
||||||
inner.add(new JTextField());
|
// inner.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||||
|
JComponent field;
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
c.ipadx = 2;
|
||||||
|
c.gridwidth = 1;
|
||||||
|
c.gridheight = 1;
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 0;
|
||||||
|
|
||||||
|
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));
|
||||||
|
inner.add(field, c);
|
||||||
|
c.gridx--;
|
||||||
|
c.gridy++;
|
||||||
|
|
||||||
|
c.weightx = 0.0;
|
||||||
|
inner.add(new JLabel("What is your current annual income?", SwingConstants.RIGHT), c);
|
||||||
|
c.gridx++;
|
||||||
|
c.weightx = 1.0;
|
||||||
|
field = new JTextField();
|
||||||
|
inner.add(field, c);
|
||||||
|
c.gridx--;
|
||||||
|
c.gridy++;
|
||||||
|
|
||||||
|
c.gridwidth = 2;
|
||||||
|
inner.add(new JLabel("What is your expected annual income after retirement -"), c);
|
||||||
|
c.gridwidth = 1;
|
||||||
|
c.gridy++;
|
||||||
|
|
||||||
|
c.weightx = 0.0;
|
||||||
|
inner.add(new JLabel(" - from an employer pension plan?", 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(" - from a part-time job?", 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(" - other?", 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("At what age do you expect to retire?", SwingConstants.RIGHT), c);
|
||||||
|
c.gridx++;
|
||||||
|
c.weightx = 1.0;
|
||||||
|
field = new JSpinner(new SpinnerNumberModel(65, 0, 150, 1));
|
||||||
|
inner.add(field, c);
|
||||||
|
c.gridx--;
|
||||||
|
c.gridy++;
|
||||||
|
|
||||||
|
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)"
|
||||||
|
};
|
||||||
|
field = new JComboBox(choices);
|
||||||
|
p.add(field, BorderLayout.EAST);
|
||||||
|
c.gridwidth = 2;
|
||||||
|
inner.add(p, c);
|
||||||
|
c.gridwidth = 1;
|
||||||
|
c.gridy++;
|
||||||
|
|
||||||
JScrollPane scrollpane = new JScrollPane(inner,
|
JScrollPane scrollpane = new JScrollPane(inner,
|
||||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
@ -49,6 +113,9 @@ class RetirementCalculatorPanel extends JPanel implements ActionListener
|
|||||||
|
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
|
System.out.println("Event:");
|
||||||
|
System.out.println(e.getActionCommand());
|
||||||
|
System.out.println(e.paramString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user