• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable joins and updates

 
Mark Dary
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have re-thought my earlier post (http://www.coderanch.com/t/426528/Swing-AWT-SWT-JFace/Regular-updates-to-table-from) and would like to ask for specific help with defining, creating and populating a JTable. I have been reading information on JTables but I would really like help wiith how to achieve the following in an efficient way, I cannot find examples that seem to help my particular situation.

I receive message objects through a socket (a byte stream really, that I convert to message objects). First I receive a variable number of M1 message objects, followed by a variable (and usually less) number of B1 message objects. The B1 messages have a one to many relationship with M1 messages (note however that I am not using a database or SQL, just raw data from an external system).

I need to store and join the M1 and B1 messages on key fields and then display them in a JTable, the resulting rows contain several different data types (strings, ints, dates, etc) and each column must have a sort function; however the data cannot be modified by the user.

The same operation (M1 block followed by B1 block) is performed at regular (user-defined) intervals, anything from 1 to 60 seconds, and the number of messages can vary between intervals from hundreds of messages to tens of thousands. The user can also send and receive other message types asynchronously.

Could anyone help with some sample code for the join and JTable manipulation as I am really confused how to best set up and use JTables.

Thanks.

Mark.

 
Darryl Burke
Bartender
Posts: 5116
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTable is designed as a UI widget, not a data structure. First decide and implement a data structure, then tie that to an extended DefaultTableModel.

Allow the model to take care of updating the JTable.

Could anyone help with some sample code

No, that's your job. Try for yourself and ask a more specific question if something eludes you.
 
Mark Dary
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Darryl

I am starting to work through the problem, I think I was looking for an idiomatic way (in Java) of joining my two blocks of data objects and how to create and update a JTable to show the joined results.

I am working through the problem (part of a very large application) and will post a specific question when/if required.

No, that's your job. Try for yourself and ask a more specific question if something eludes you.

Yep, thats a fair comment, I was just hoping to speed things up.

Mark.
 
Darryl Burke
Bartender
Posts: 5116
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could take a look at the MVC Pattern.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic