Results 1 to 2 of 2
  1. #1
    drgnfire25 is offline Member
    Join Date
    Jan 2011
    Posts
    24
    Rep Power
    0

    Default Arraylist display problem

    is there an easy way to display an arraylist in a jtable or even just in columns??

    Java Code:
            resultgrad = getgraduate.query();//get list of grads
                //get all grads
                  Iterator<student> itr = resultgrad.iterator();
                    while (itr.hasNext()) {
                      student element = itr.next();
                      String x = element.toString().toUpperCase();
                      if (x.contains("NON-RESIDENT")){
                          System.out.println("you got it");
                          tution = (getgraduate.calculateTuition(12, "NON-RESIDENT"));
                      }
                     else{
                          tution = (getgraduate.calculateTuition(12, "RESIDENT"));
                     }
                      stuData.append(element + " " + tution + "\n");
    
                    }

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

    Default

    The easiest is probably to create a DefaultTableModel object, and iterate through your ArrayList in a for loop adding rows to the model with the data held in the ArrayList, and then use this model as the model of your JTable.

Similar Threads

  1. Problem- arraylist
    By whizzz in forum New To Java
    Replies: 3
    Last Post: 12-05-2010, 01:13 AM
  2. ArrayList problem.
    By keo in forum New To Java
    Replies: 4
    Last Post: 10-15-2010, 11:22 AM
  3. Arraylist problem
    By keo in forum New To Java
    Replies: 3
    Last Post: 05-28-2010, 10:38 AM
  4. Hey! ArrayList problem here
    By Samgetsmoney in forum New To Java
    Replies: 31
    Last Post: 02-20-2009, 12:39 AM
  5. Replies: 3
    Last Post: 01-29-2009, 10:20 AM

Posting Permissions

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