Jtable Keep content updated + sorted

I have an array of beans, the beans contain about 8 fields each

I want each bean to represent a row of the jtable, 8 columns = 1 for each field.
I want the software to create the array of beans, post them to the Jtable, create the array of beans again (this time with updated information) then post the updated beans to the Jtable.  I also want to be able to sort the Jtable that is constatly being updated by any column.

{
TableModel jTable1Model = new DefaultTableModel(
new String[][] { { "One", "Two" },
      { "Three", "Four" },
      { "Three", "Four" } },
new String[] { "Column 1", "Column 2", "Column 3" });
      jTable1 = new JTable();
      this.getContentPane().add(jTable1, BorderLayout.CENTER);
      jTable1.setModel(jTable1Model);
}
qbawler311Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
objectsCommented:
To use your bean array in a table you'll need to extend AbstractTable model and have getValueAt() return the appropriate porperty for each column

Heres an example of a sortable table

http://www.objects.com.au:8088/objects/java/examples/swing/SortableTable.do
0
Mayank SAssociate Director - Product EngineeringCommented:
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

qbawler311Author Commented:
>> http://www.objects.com.au:8088/objects/java/examples/swing/SortableTable.do

Firewall refuses connection to this link.  Could you paste the code in here?
0
qbawler311Author Commented:
>> http://www.javareference.com/jrexamples/viewexample.jsp?id=17

If you guys could show me how to add the code to make the table at the above link sortable that is exactly what i am looking for.  Having trouble combining the information I am reading from the "AbstractTableModel" example and the "TableSorter" examples.  thank you
0
qbawler311Author Commented:
To compensate for the extra help I need I'm happy to up the points.  I haven't made any good GUI's...:-)
0
qbawler311Author Commented:
>>try:
>>
>>http://www.objects.com.au/java/examples/swing/SortableTable.do

this link worked, but the links on the page didn't...I will try at home later.
0
objectsCommented:
thanks for pointing that out. The ISP has just upgrade the server and it looks like it broke some links.
While I get them fixed you can manually fix the url by removing the :8088/objects
sorry for the inconvenience.
0
qbawler311Author Commented:
OK I got it let me get back my 200 points I added and I will split up the 200 originally posted?
0
Mayank SAssociate Director - Product EngineeringCommented:
Not sure if you can reduce the points (it probably says Increase only)
0
hoomanvCommented:
the first post provides everything you need to sort a table
posting over posts would confuse the asker ;-/
0
qbawler311Author Commented:
The other half of the question is how do I keep the Array of objects that I am displaying in the sorted Jtable refreshed and sorted as they are updated?...without hitting any buttens.
0
hoomanvCommented:
the tablesorter model would take responsibility of that as you only need to update cells
0
hoomanvCommented:
compile and run the example, try to alter the cells, and you'll find out how it works
in short
you only need to wrap your own TableModel into TableSorter model
then pass it to yourtable's setModel method
nothing more
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.