Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Amortization Schedule Table Help.

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Amortization Schedule Table Help.

    Hi, I am making an Amortization Schedule and am having trouble with the table. Is there a way to set the number of rows in the table? Can I set that based off of how many payments the user will make on their loan. Thanks!

    Code:

    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
     
    	}
     
     
     
     
     
     
    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Amortization Schedule Table Help.

    Moderation: original moderated post "approved" and is now visible.

    As for your number of rows -- that equals the number of payments and is part of the amortization formula.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Amortization Schedule Table Help.

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/67363-amortization-schedule-table-help.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


Similar Threads

  1. [SOLVED] Need Help Generating Loan Repayment Schedule
    By C++kingKnowledge in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 3rd, 2012, 02:11 PM
  2. How to schedule this to happen daily?
    By dynamix24 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 25th, 2012, 07:19 PM
  3. Timer.schedule
    By johnboyofsj in forum Java Theory & Questions
    Replies: 1
    Last Post: October 14th, 2012, 11:02 PM
  4. Amortization Loan, works, but need suggestions please.
    By TheWhopper858 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 17th, 2011, 04:38 AM
  5. How to schedule a Java Program for Background processing
    By rangarajank in forum Java Theory & Questions
    Replies: 5
    Last Post: May 13th, 2010, 04:57 AM