This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes EventDispatch Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "EventDispatch Exception" Watch "EventDispatch Exception" New topic
Author

EventDispatch Exception

ghazanfar khan
Ranch Hand

Joined: Apr 18, 2005
Posts: 81
Hello,
I have an application which frequently update and download its data from stock market, but when i pass the my table model in TableSorter it throws an eventdispatch excption, but the program wruns fine. i also calling invokeLater from my main class. Can anyone please help me why or can someone explain me wht is eventdispatch thread. I read some article on web but not get clear idea. Please help me out
thank you very much.
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1441
You may want to post your code so people can see exactly what is going on.


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
ghazanfar khan
Ranch Hand

Joined: Apr 18, 2005
Posts: 81
thanks John for your reply, i am using TableSorter class from sun web site. It works fine when the i have static data, but i am getting data from the stock market, so it is changing, here is the link for tableSorter

private Row[] getViewToModel() {
if (viewToModel == null) {
int tableModelRowCount = tableModel.getRowCount();
viewToModel = new Row[tableModelRowCount];
for (int row = 0; row < tableModelRowCount; row++)
{
viewToModel[row] = new Row(row); <--THIS IS THE LINE
CAUSING THE EXCEPTION
}

if (isSorting()) {
Arrays.sort(viewToModel);
}
}
return viewToModel;
}

Why would a Null Pointer Exception be occurring here if we are assigning a value???

thanks in advance
[ January 03, 2006: Message edited by: ghazanfar khan ]
ghazanfar khan
Ranch Hand

Joined: Apr 18, 2005
Posts: 81
i have solved the problem, here is the solution we need to inform tableSorter by using Event Thread e.g

**********************************************************************
try{
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
tableModel.fireTableDataChanged();
}

});
}catch(InterruptedException ie){

}catch(InvocationTargetException te){

}

**********************************************************************
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1441
Glad you found the solution!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: EventDispatch Exception
 
Similar Threads
Swings, Threads, MVC: plz clarify
How to Prevent JSP Page from Being Cached?
Message Box problem
selection box values from database
How to implement EventDispatch in threads