Results 1 to 3 of 3
  1. #1
    xe0nre is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

    Default Update Jtable from Arraylist

    First I want to say "Hello" to all forum members..

    I have a problem...I have created an application that helps my dad manage his music CDs.
    My Problem is that i want to create a jtable that updates based on my Arraylist<Song>..

    This is what i have:

    My Song Class:
    Java Code:
    public class Song implements Serializable 
    {
    	private String artist;
    	private String album;
    	private String track;
    	
    	public Song(String artist,String album,String track)
    	{
    		this.artist = artist;
    		this.album = album;
    		this.track = track;
            }
    }
    I also have an ArrayList<Song> that i use to create my "CD".
    And i have a Jtable with collums {"Artist","Album","Track"}.

    I understand that i have to create a TableModel....can you please help me with that..:)

    Thanks

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,580
    Rep Power
    25

    Default

    I'd start in the Tutorial and get examples there on how to use JTable and go from there.
    Go here:The Really Big Index
    and Search for Tables

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,662
    Blog Entries
    7
    Rep Power
    21

    Default

    For a jump start read the API documentation for the AbstractTableModel class; you have to extend it and you only have to implement three small methods. If you want your table to be updatable you have to implement a fourth small method; it's easy. But for a complete understanding of JTables and their TableModels do as Norm suggested.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Update arraylist based on some conditions
    By emyk in forum Advanced Java
    Replies: 11
    Last Post: 04-13-2011, 05:18 PM
  2. how tu update a JTable
    By Timmins in forum New To Java
    Replies: 0
    Last Post: 04-01-2011, 10:19 PM
  3. update arraylist to mysql database
    By sks in forum JDBC
    Replies: 11
    Last Post: 04-01-2011, 08:26 AM
  4. JTable update...
    By chyrl in forum Advanced Java
    Replies: 1
    Last Post: 01-30-2011, 02:25 PM
  5. update jtable?
    By realosso in forum New To Java
    Replies: 0
    Last Post: 08-03-2010, 11:31 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
  •