import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class AmortizationGUI extends JFrame implements ActionListener {
public AmortizationGUI(){
Font font = new Font("Arial",Font.PLAIN,16);
Font fieldFont = new Font("Arial", Font.PLAIN,14);
//JFrame attributes
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Amortization Schedule");
setSize(800,800);
setLocationRelativeTo(null);
setResizable(false);
//initialize panel
JPanel panel = new JPanel();
panel.setLayout(null);
//initialize JLabels
JLabel lA = new JLabel("Loan Amount:");
lA.setLocation(50,50);
lA.setFont(font);
lA.setSize(100,50);
lA.setVisible(true);
JLabel iR = new JLabel("Interest Rate:");
iR.setSize(100,50);
iR.setFont(new Font("Arial",Font.PLAIN,17));
iR.setLocation(50,100);
iR.setVisible(true);
JLabel yL = new JLabel("Years of Loan:");
yL.setSize(100,50);
yL.setLocation(49,150);
yL.setVisible(true);
yL.setFont(font);
//initialize JTextFields
JTextField lAField = new JTextField(40);
lAField.setSize(70,20);
lAField.setLocation(150,66);
lAField.setVisible(true);
lAField.setFont(fieldFont);
lAField.setBorder(BorderFactory.createLineBorder(Color.BLACK));
JTextField iRField = new JTextField(10);
iRField.setSize(70,20);
iRField.setLocation(150,116);
iRField.setVisible(true);
iRField.setFont(fieldFont);
iRField.setBorder(BorderFactory.createLineBorder(Color.BLACK));
JTextField yLField = new JTextField(10);
yLField.setSize(70,20);
yLField.setLocation(150,166);
yLField.setVisible(true);
yLField.setFont(fieldFont);
yLField.setBorder(BorderFactory.createLineBorder(Color.black));
//initialize button
JButton calc = new JButton("Calculate");
calc.setSize(100,50);
calc.setLocation(100,206);
calc.setVisible(true);
calc.setFont(font);
calc.setBorder(BorderFactory.createLineBorder(Color.BLACK));
//button ActionListener
//initialize table
JTable table;
String columnNames[] ={"Payment #","Amount Paid","Principal","Interest","Balance"};
Object data[][] = {
{"","","","",""}
};
table = new JTable(data,columnNames);
table.setPreferredScrollableViewportSize(new Dimension(400,100));
table.setFillsViewportHeight(true);
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBounds(250,200,500,500);
//adding elements
panel.add(lA);
panel.add(iR);
panel.add(yL);
panel.add(lAField);
panel.add(iRField);
panel.add(yLField);
panel.add(calc);
panel.add(scrollPane);
panel.setVisible(true);
add(panel);
}
public static void main(String[] args){
AmortizationGUI gui = new AmortizationGUI();
gui.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}