Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
I have been trying to create a JFormattedTextField array which populates in a pane. Once a click event occurs, the actions get processed and the textfields are populated using setText(). The code for the array and initializing is in the constructor method here:
JFormattedTextField[] balance=new JFormattedTextField[360];
JFormattedTextField[] paidInt=new JFormattedTextField[360];for(count=0;count<360;++count)
{
counter[count]=Integer.toString(count + 1);
labPayment[count]=new JLabel(counter[count]);
scheduler.add(labPayment[count]);
balance[count]=new JFormattedTextField(amountFormat);
scheduler.add(balance[count]);
balance[count].addActionListener(this);
paidInt[count]=new JFormattedTextField(amountFormat);
scheduler.add(paidInt[count]);
paidInt[count].addActionListener(this);
}And finally, in the Action Performmed method I have the following to send back the text to those fields here:
if(e.getSource()==butSchedule)
{
for(calc2count=0;calc2count<360; ++calc2count)
{
paidint[calc2count]=dmtgAmount * (dmtgRate / 12);
payout[calc2count]=dmtgPayment- paidint[calc2count];
dmtgAmount=dmtgAmount - payout[calc2count];
stBalance[calc2count]=Double.toString(dmtgAmount);
stpaidInt[calc2count]=Double.toString(paidint[calc2count]);
// balance[calc2count].setText(stBalance[calc2count]);
// paidInt[calc2count].setText(dollarsandcents.format(stpaidInt[calc2count]));
System.out.println((stBalance[calc2count]);
System.out.println(" ");
System.out.println((stpaidInt[calc2count]);
System.out.println(" ");
//if structure used to default to $0 if the loan balance becomes $0 or less
if(dmtgAmount<0)
break;
//if structure used to default to $0 if the interest becomes $0 or less
if(paidint[calc2count]<0)
break;
}
}// balance[calc2count].setText(stBalance[calc2count]);
// paidInt[calc2count].setText(dollarsandcents.format(stpaidInt[calc2count]));