super("MORTGAGE CALCULATOR");
grid1 = new GridLayout(1,10,5,5); //(rows, columns, vertical space, hortizontal space)
c = getContentPane();
c.setLayout(grid1); //layer the format
//addition of Menu bar
JMenuBar bar = new JMenuBar();
setJMenuBar(bar);
//addition of main menu bar item
JMenu calMenu = new JMenu("CALCULATE");
calMenu.setMnemonic('L'); //Hot Key
bar.add(calMenu);
//addition of first item for File
JMenuItem thirtyMenu = new JMenuItem("1-30 Years");
thirtyMenu.setMnemonic('1');
thirtyMenu.addActionListener(
new ActionListener(){ //Listen to the Keyboard
public void actionPerformed(ActionEvent e){ //Set to 30 Years and 5.75%
String S_Amount="200000";
String S_Year = "30";
String S_Percent = "5.75";
textAmount.setText(S_Amount);
textYears.setText(S_Year);
textInterest.setText(S_Percent);
}
}
);
calMenu.add(thirtyMenu);
//addition of second item for File
JMenuItem fifteenMenu = new JMenuItem("2-15 Years");
fifteenMenu.setMnemonic('2');
fifteenMenu.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){ //Set to 15 Years and 5.5%
String S_Amount="200000";
String S_Year = "15";
String S_Percent = "5.5";
textAmount.setText(S_Amount);
textYears.setText(S_Year);
textInterest.setText(S_Percent);
}
}
);
calMenu.add(fifteenMenu);
//addition of second item for File
JMenuItem sevenMenu = new JMenuItem("3-7 Years"); //Set to 7 Years and 5.35%
sevenMenu.setMnemonic('3');
sevenMenu.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
String S_Amount="200000";
String S_Year = "7";
String S_Percent = "5.35";
textAmount.setText(S_Amount);
textYears.setText(S_Year);
textInterest.setText(S_Percent);
}
}
);
calMenu.add(sevenMenu);
//addition of second main menu bar
JMenuItem clearMenu = new JMenuItem("CLEAR");
clearMenu.setMnemonic('R');
clearMenu.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
textMpayment.setText(null);
textInterest.setText(null);
textYears.setText(null);
area1.setText(null);
textAmount.setText(null);//clear program;
}
}
);
bar.add(clearMenu);
//addition of third main menu bar
JMenuItem exitMenu = new JMenuItem("EXIT");
exitMenu.setMnemonic('E');
exitMenu.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
}
);
bar.add(exitMenu);
//Text Labels
labelAmount = new JLabel(" Amount ");
labelYears = new JLabel(" Years ");
labelInterest = new JLabel(" Interest ");
labelMpayment = new JLabel(" Monthly Payment ");
//Text Boxes 5 wide
textAmount = new JTextField(10);
textYears = new JTextField(2);
textInterest = new JTextField(3);
textMpayment = new JTextField(10);
//Calculate Button
buttonCalc = new JButton("Calculate");
//Add Buttons and Lables
c.add(labelAmount);
c.add(textAmount);
//additoin of Horizontal Scroll bar to area1 Text Area
Box b = Box.createHorizontalBox();
JScrollPane scrollPane = new JScrollPane(area1);
addComponent ((new JScrollPane(area1)), 8, 0,9,9);
//Size of the Window
setSize (820, 480);
show();
}
public static double Formula (double Amount, double Years, double Interest){