Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Fubarable

Thread: ActionListener with for loop problem

  1. #1
    pj6444 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    165
    Rep Power
    2

    Default ActionListener with for loop problem

    Hello, I am making an Amortization Schedule, and when I press my calculate button, it adds rows to the table and sets values to variables. When I only use the for loop it works great, but when I use the variables the program does nothing when I press the button.
    ActionListener code:
    Java Code:
    public void actionPerformed(ActionEvent event) {
    		if(event.getSource()==calc){//calc is button
    			//these are for the calculations
    			yearsLoan = Integer.parseInt(yLField.getText());
    			interestRate = Integer.parseInt(iRField.getText());
    			loanAmount = Integer.parseInt(lAField.getText());
    			//adds rows for the number of payments
    			for(int counter = 0;counter<=12*yearsLoan;counter++){
    				DefaultTableModel.addRow(data);//data is a vector
    			}
    		}

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: ActionListener with for loop problem

    Where do you create and put information into the data vector? You would need to do this inside of the for loop where you would create a new Vector, set the data that it holds with each iteration of the for loop.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: ActionListener with for loop problem

    Shoot you've already asked this question elsewhere on this site. Please don't waste the forum member's time re-asking the same question in multiple locations. This is not fair to us and is not appreciated. Locking.
    DarrylBurke likes this.

Similar Threads

  1. Have problem with add.ActionListener()
    By emily.m in forum AWT / Swing
    Replies: 5
    Last Post: 02-22-2012, 09:36 PM
  2. Problem with ActionListener?
    By Manish87 in forum AWT / Swing
    Replies: 5
    Last Post: 03-31-2011, 02:54 PM
  3. no return- problem with actionlistener
    By lparadiso in forum AWT / Swing
    Replies: 2
    Last Post: 11-21-2010, 02:31 AM
  4. Problem Actionlistener
    By Questionmark in forum New To Java
    Replies: 18
    Last Post: 08-07-2010, 12:29 PM
  5. ActionListener run automatically problem
    By cassysumandak in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 09:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •