Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Real-time GUI and polling

 
John Cogan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a main() which starts two threads, one which polls a device and populates a hashtable and the other an event-dispatcher GUI thread with uses a TableModel to take data from the hashtable and draw a table.

In debug mode an exception is thrown in the java.awt.Container class:

throw new ArrayIndexOutOfBoundsException("No such child: " + n);

at this line
javax.swing.SwingUtilities.invokeLater(new Runnable() {

I reckon I'm not initializing something in the GUI properly but can't think what.
I would be very gateful for any ideas on this.


public static void main(String[] args) {

WebPortalSimulator x = new WebPortalSimulator();
x.start();

javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
MainWindow mainWindow = new MainWindow();
}
});

}
 
Jared Cope
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My guess is that unless your threads are synchronizing with each other, the reading thread might be trying to read something that isn't actually there.

Without seeing your code, I suspect this is why the index position is out of bounds on the reading thread.

Cheers, Jared.
[ January 25, 2005: Message edited by: Jared Cope ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic