my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes Real-time GUI and polling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Real-time GUI and polling" Watch "Real-time GUI and polling" New topic

Real-time GUI and polling

John Cogan
Ranch Hand

Joined: Jan 22, 2003
Posts: 32
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();

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


----------------<br />SCJP, SCWCD
Jared Cope
Ranch Hand

Joined: Aug 18, 2004
Posts: 243

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 ]

SCJP 1.4 91%, SCJP 1.5 88%, SCJD B&S
I agree. Here's the link:
subject: Real-time GUI and polling
jQuery in Action, 3rd edition