kaharas
kaharas

Reputation: 607

Bind arraylist to jtable

recently I wrote a C# application, that simply rendered the elements of a list ( named lst) of objects into a table, with the following code:

DataTable dt = Request.ListToDataTable(lst);
dw = new DataView(dt);
dw.Sort = "columnb ASC";
dataGridView1.DataSource = dw;

now i need to do something similar in java : is it possible? or i have to create a tablemodel and working with it? Let's say I've a list of Person objects, and I want to build a table containing surname, name and age. Is it possible to do it in a smart way ?

Upvotes: 1

Views: 4262

Answers (2)

camickr
camickr

Reputation: 324088

or i have to create a tablemodel

Yes you will need a custom TableModel.

You can use the Bean Table Model which allows you to create the model and the table in two lines of code.

Upvotes: 2

Jochen Bedersdorfer
Jochen Bedersdorfer

Reputation: 4122

It is certainly possible. The question is: what web framework are you going to chose? Most of them offer data binding on a proper model-view-controller concept.

Upvotes: 1

Related Questions