[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] problem updating Text

I have a page with the contains two components:
a Canvas with an Image
Text (showing year #)

I have a loop which does some calculations, updates & displays the image, and updates the year.

As it loops thru, the image changes with each year.
The problem is that the year does not change with each year.
It starts out as 0, stays that way until the loop is finished, and then displays 99, despite calling redraw() and update()


How can I fix this?

myCanvas extends Canvas, Image image, Text yearNumber

for (int i = 0; i <= 99; i++)
{
  doNumberCrunching();  //calculations will cause image to change

  myCanvas.resetImageData();   // this changes pixel values
  image = new Image(display, imageData);

  myCanvas.redraw(); // put a redraw event on the OS event queue
  myCanvas.update(); // force redraw

  // update the year displayed
  yearNumber.setText(new Integer(i).toString());
  yearNumber.redraw();
  yearNumber.update();

} // end for