• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JTable

 
Manan Pacholi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

/*************************************************************************************************************/
Actually I'm trying to display the captured packet details in the JTable which follows DefaultTableModel. Now I encapsulate all the fields of the packet into a string and I try to add this string into my table as a new row. But no changes are reflected in my table. Also in the GUI once I hit the START button to start packet capture, my application goes dumb and stops responding! To find a reason for this problem, I added those print statements in between to see whether my code is running properly or it gets stuck somewhere. But the code is running properly, I can see the results of println statement on my screen, but the table is not updated and the application window freezes. Please someone help me with this. Thanks.
 
Rob Camick
Ranch Hand
Posts: 2669
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please edit your posting and repost the code using the "Code" tags. Once the code is pasted you selected the code and then click the "Code" button.

> Also in the GUI once I hit the START button to start packet capture, my application goes dumb and stops responding!

This is because you are blocking the Event Dispatch Thread with your packet listener so the GUI never gets a chance to respond to events and repaint itself.

Read the section from the Swing tutorial on Concurrency for an explanation. You should be using a Swing Worker.
 
Manan Pacholi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry about the way in which I put my code first....but I've corrected it now......thanks for the reference to concurrency in swing....will definitely go through it....but what I'm really concerned about right now is why the table is not refreshed.....do you think that it is because of the thread problem that you mentioned? please help me out.....Thanks...
 
Manan Pacholi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Ok now I have used the SwingWorker thread for capturing packets, and so my application does not become 'DUMB' as it used to before.....but still my jtable stays blank still......! Please guys help me nail this problem......I am so very desperate......
 
Manan Pacholi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Come on guys......please help me...I'm stuck because of this little problem.....and it is driving me nuts!
 
Rob Spoor
Sheriff
Pie
Posts: 20750
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even then, PatienceIsAVirtue.

Anyway, the problem is in the process method. You haven't overridden it, you've overloaded it. The method should be this:
You need to process all elements of the List, since SwingWorker may choose to buffer the published values and let you process more than one at a time.
Also, DefaultTableModel's insertRow method already fires the necessary events, so no need to manually fire any.

Oh, and you may want to move line 75 (the publishing) outside the if-statement. If eth_pkt.frametype==EthernetPacket.ETHERTYPE_ARP nothing will be published now.
 
Rob Camick
Ranch Hand
Posts: 2669
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be Forthright When Cross Posting To Other Sites

I see you received and answer in your cross posting: http://stackoverflow.com/questions/6655141/java-swing-problem-updating-the-jtable.

So why haven't you responded to this posting indicating a solution has been found so people don't waste time answering questions that have already been answered. It amazes me how selfish people can be. First you complain because we don't respond fast enough. Then you don't post the answer when you find one.


 
Manan Pacholi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry guys for not updating the status of this query.....I'll make sure it won't happen again.............but my problem with JTable has been solved....yes the problem was definitely in my process method....


 
Manan Pacholi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manan Pacholi wrote:Sorry guys for not updating the status of this query.....I'll make sure it won't happen again.............my problem with JTable has been solved....yes the problem was definitely in my process method....


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic