Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:13:46+00:00 2026-05-27T18:13:46+00:00

I need some help understanding why the ArrayList is not being populated, I am

  • 0

I need some help understanding why the ArrayList is not being populated,

I am trying to pass information Stored in a jTable that is on a JFrame to a JTextArea taht is on another JFrame, i curently have the following code but for some reason the information is not being passed, it stays Empty

I dont want Anyone to do my HW for me i just need to be pointed in the right direction,

here is the Code i did so far.

     public ArrayList<String> extractTableInfo() {

    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();

    int nRow = model.getRowCount(), nCol = model.getColumnCount();


    ArrayList<String> extractedInfo = new ArrayList<String>();

    String rowInfo = "";

    for (int i = 0; i < nRow; i++) {
        for (int j = 0; j < nCol; j++) {
            rowInfo = rowInfo + (String) model.getValueAt(i, j);
        }
        extractedInfo.add(rowInfo);
    }

    return extractedInfo;
}

Thats in the First JFrame and in the second JFrame on button Click i have

     private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         


    Generate_Teams gt = new Generate_Teams();

     ArrayList<String> TableInformation = new ArrayList<String>();

     for(int i =0; i < gt.extractTableInfo().size(); i++){         
     TableInformation.add(gt.extractTableInfo().get(i));
     }



    for (int i = 0; i < TableInformation.size(); i++) {
        jTextArea1.append(TableInformation.get(i));
    }


}                                        

i would apriciate any help you can give.

Thx in advance…..

Fix….

Thx for your help fixed it like this,

 Edit ed = new Edit(extractTableInfo());

 ed.setVisible(true);

that is in the First Frame and in the second frame i did this

private ArrayList<String> infogot = new ArrayList<String>();

  public Edit(ArrayList<String> getinfo)
 { 
   initComponents();
   this.infogot = getinfo;

 }


   for (int i = 0; i < infogot.size(); i++) {
      jTextArea1.append(String.valueOf(infogot.get(i)));
    }

And it worked like this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:13:47+00:00Added an answer on May 27, 2026 at 6:13 pm

    Try debugging your code. It might help adding print statements to check if the ArrayList returned by the extractTableInfo method contains the contents of the table.

    Also, the loop below could be improved:

    for (int i = 0; i < gt.extractTableInfo().size(); i++) {
       TableInformation.add(gt.extractTableInfo().get(i));
    }
    

    It looks like whenever you call extractTableInfo you are creating a new ArrayList and populating it from the table over and over again.

    Instead use:

    ArrayList<String> extractedInfo = gt.extractTableInfo();
    for (int i = 0; i < extractedInfo.size(); i++) {
       TableInformation.add(extractedInfo.get(i));
    }
    

    Or even better, use:

    TableInformation.addAll(gt.extractTableInfo());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help understanding this bit of code pre { white-space: pre; white-space:
I need help understanding some C++ operator overload statements. The class is declared like
Need some help assigning a mouseover event to display some icons that start out
Need some help understanding why my concat() is failing and how to fix it.
I need some help understanding some of the points from Paul Graham’s What Made
I need some help understanding what's happening here. This code is from a models/log.py
I need some help understanding the correct way to mix variables with strings like
I need some help understanding how stdext::hash_multimap's lower_bound, upper_bound and equal_range work (at least
I'm new to ORM stuff and I need some help understanding something. Let's assume
I need some help at understanding how foreign keys and cascades work. I understood

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.