Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

J2ME -- Need help on how to refresh an image

  Asked By: Darcy    Date: Jun 03    Category: Java    Views: 921

I need some help on how to refresh an image.

Basically I am loading a webcam image on the webserver and I want to
refresh it maybe every 3sec..

I am managing to load the image but now im stuck on how to refersh
the image .



3 Answers Found

Answer #1    Answered By: Taylor Evans     Answered On: Jun 03

You might want to have your "main" class implement
runnable then load  the image  in the run() method. Put
a sleep(3000) at the end of run() then call new
Thread(this).start() in your constructor.

Now this is just an idea to get you started. The
implementation details are up to you. For example, you
might need a way to kill the Thread that you started
so you must store it in an instance variable.

Answer #2    Answered By: Benjamin Simpson     Answered On: Jun 03

Well... I sort of managed to make the image refresh  by doing a loop

and calling this logic every time

" private void refreshImage() {

int i = imageList.getSelectedIndex();
imageName = (String) imageNames.elementAt(i);
thread = new Thread(this);
as it refreshes it will not let me do anthing else unless i press
the cancel button.

Also when i tested it on the series 60 emulator everytime I refresh
it asks me if I want to do aconnect asI am all the time calling the

c = (HttpConnection) Connector.open(name);
int status = c.getResponseCode();
if (status != 200) {
throw new IOException("HTTP Response Code = " + status);

and also in the Series 60 the image  is becoming null when refreshed :
( so Im really stuck...

Answer #3    Answered By: Adalwen Fischer     Answered On: Jun 03

Is this the line that call the method to reload the

If it is you'll have to put that in your run method
otherwise the process will block when it reaches that

Also, I'm not sure if it's available on J2ME but you
might want to look into the MediaTracker class.

Didn't find what you were looking for? Find more on J2ME -- Need help on how to refresh an image Or get search suggestion and latest updates.