This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable joins and updates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable joins and updates" Watch "JTable joins and updates" New topic
Author

JTable joins and updates

Mark Dary
Greenhorn

Joined: Jan 16, 2009
Posts: 29
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

Joined: May 03, 2008
Posts: 4523
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Mark Dary
Greenhorn

Joined: Jan 16, 2009
Posts: 29
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

Joined: May 03, 2008
Posts: 4523
    
    5

You could take a look at the MVC Pattern.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable joins and updates
 
Similar Threads
jtable not updating properly...
Regular updates to table from network messages
Hard JTABLE Question
JTable(!!!)
jtable