im currently creating a simple GUI app. where a Jtable is used. now within the table there are 5 columns of data to be displayed, i was thinking if i can model the data displayed on that by creating a class.
Now, if do create a class, i dont know which collection to use, a haspmap or a vector. i have ideas on both , but havent decided which one to use.
Can you give some thoughts about this situation.. and may you recommend which may i use.
There are couple of ways you can make table in Swing. You can use default model (data class) which is created by Sun <-Thanks! Also you can create your own model class (it takes more time, but the possibilities are almost endless). Heh, well all of this is probably in the link above.
Regarding containers: Vector is a growable array of objects... You know a, a etc. While HashMap is a map: "John"->JohnObject, "Peter"->PeterObject. Anyway I don't use Vector. If I need array like behavior I use ArrayList. Their main difference the latter is not synchronized (but you can synchronize it later).
posted 13 years ago
ive noticed that the data in the sample on the link you've given are already given TableDemo, which is the variable named data of type Object.
So correct me if im wrong, the data model then is the model for the data this includes its operations (add rows, delete rows, etc). And to update the view(JTable) and its contents we can implement event handlers which i think is the TableModelListener. I will therefore create added methods for creating a new row of data, this means adding a new object on variable data and likewise for deleting?
Am I correct on this.. [ February 12, 2007: Message edited by: Cyrus Serrano ]