02-09-2012 11:59 AM
HI
Im trying to replace a bitmaptField from a background thread and it throws a
IllegalArgument Exception Manager.replace: Oldfield is not a child.
Is there anyway i can get this working? because what im trying is to pass images to the bitmapfield in my mainscreen. any suggestions?
Thanks
02-09-2012 11:38 PM - last edited on 02-09-2012 11:39 PM
A background thread cannot operate on the GUI - only the event thread can do this.
You can wrap the GUI operation in a Runnable, and pass this runnable to UiApplication.invokeLater().
This places the GUI work in the event queue, where it will be handled by the event thread.
02-10-2012 04:30 AM
Yeah RexDoug...Ive wrapped it in a runnable object and done hte invoke later. What i noticed was i could add a new bitmapField from the background but I cant replace the existing one.
Please have a look at this
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
synchronized (camView)
{
try
{
camView.jpegBytes = jp;
System.out.println(bit);
test t = new test();
BitmapField bmpField = new BitmapField(bit);
System.out.println("Replacing BitmapField.");
t.replace(camView.bmpStream,bmpField );
t.invalidate();
System.out.println("Successfully replaced.");
}
catch(IllegalArgumentException e)
{
System.out.println("Exception while displaying streaming images: " + e.getMessage());
}
}
}
});
02-10-2012 05:46 AM - last edited on 02-10-2012 06:42 AM
Hi, roses_r
You put your code like this.
_workThread = new Thread(new Runnable() {
public void run() {
try {
synchronized (Application.getEventLock()) { camView.jpegBytes = jp;
System.out.println(bit);
test t = new test();
BitmapField bmpField = new BitmapField(bit);
System.out.println("Replacing BitmapField.");
t.replace(camView.bmpStream,bmpField );
t.invalidate();
System.out.println("Successfully replaced."); }
} catch (Exception e) {
}
}
});
_workThread.start();
I hope you error sloved.
02-10-2012 06:13 AM
whats this processSuccess method u have used?
02-10-2012 06:43 AM
Sorry.There are some extra field now i edit my old post so check it out,
Thanks.
02-10-2012 06:56 AM
well i removed them before and tried as well..didnt work for me
still throws an excception saying
Manager.replace: Old field is not a child
02-18-2012 08:18 AM
Have a look at my response in the other Thread in which you posted a similar question: