This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Set data from arraylist into jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Set data from arraylist into jtable" Watch "Set data from arraylist into jtable" New topic

Set data from arraylist into jtable

rahul S Sharma

Joined: Jun 08, 2011
Posts: 21
Hi All,

I am getting data in my ArrayList. Now I want that data to be placed in jtable through AbstractTableModel. How can i achieve this.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43391
I presume you have been through tutorials etc?
rahul S Sharma

Joined: Jun 08, 2011
Posts: 21
Hi Ritchie
Thanks for your help. I have gone through the tutorial but didn't find any solution related to my problem. So I would appreciate if you could give some guidelines or any link that can solve my problem....

Rob Spoor

Joined: Oct 27, 2005
Posts: 20049

The "Creating a Table Model" section should be able to help you along the way. They use an Object[][], but using a List is not much different.

How To Ask Questions How To Answer Questions
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2360
You can use Row Table Model as a starting point (after reading the Swing tutorial).
Haris Tasawar
Ranch Hand

Joined: Aug 19, 2011
Posts: 30
Yes you can... you can simply create a class which extends a table model e.g abstract table model and just implement the table model methods i.e getcolumncount(), getrowcount() and getbvalueat() methods... and you`ll be good to go.
jQuery in Action, 3rd edition
subject: Set data from arraylist into jtable
It's not a secret anymore!