Create JTable using data from a while loop?
843807Jan 25 2010 — edited Jan 25 2010Is it possible to display data in a table that comes directly from a loop? I've tried using JTable to accomplish this, but it seems as though it wants a fixed and number of rows and columns to create the table. I'm wanting to create column titles and then fill each row with data from a loop that will count down.
Here's what I mean...
The loop:
while (loanAmount > 0)
{
for (int i = 0; i < 12; i++)
{
interestPaid = loanAmount * monthlyRate;
principlePaid = monthlyPymt - interestPaid;
loanAmount = loanAmount - principlePaid;
pymtNo = pymt;
}/
}
The table:
Month Monthly Payment Interest Paid Remaining Principle
___________________________________________________________________________________
pymtNo monthlyPymt interestPaid loanAmount
I want to create a new row in the table until loanAmount is zero. Is that possible? And if so, can someone tell me the best approach? I'm not asking for code, more like instructions on how to go about it.