Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create JTable using data from a while loop?

843807Jan 25 2010 — edited Jan 25 2010
Is 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 22 2010
Added on Jan 25 2010
9 comments
1,190 views