Praveen,

I'm not completley sure what's going on in your app, but you
might be seeing the effect of Swing's use of a back buffer.
That is, in an AWT app, you see the graphics on the screen
at the same time that you draw them.  But in Swing, all
graphics are rendered to the back buffer and you only
see them on the screen when the back buffer is copied to
the screen.

If you want to present the data as it becomes available, only do
the rendering itself in the paintComponent() method.  You could
use a separate thread to prepare the data and then, whenever
you are ready to display new data, call repaint() on the
component, which will eventually call your paintComponent()
method, which will quickly display only the data that you
have specified is ready.

Hope that helps.

Chet.
Java2D


Praveen Kysetti wrote:


Hi,
I am trying to render a tiled OffScreen image onto a JPanel one tile at
a time.  It works fine if I use the AWT Canvas or it even works if its a
JPanel added into a AWT ScrollPane but doesn't work if its pure swing.
In a swing component it waits for all the tiles to be loaded before it
draws it onto the JPanel. Is it possibly because the computing thread
hanging. I have attached my paint method for the JPanel below. It might
give you some idea of what I want to do. I can't figure out what's
wrong. Hope you can give some suggestions. Any help is appreciated.

Thanks,
Regards,
Praveen
******************************************************************************
public synchronized void paintComponent(Graphics g) {
   Graphics2D g2D  = (Graphics2D)g;
   Rectangle clipBounds = g.getClipBounds();
   txmin = XtoTileX(clipBounds.x);
   txmax = XtoTileX(clipBounds.x + clipBounds.width - 1);
   tymin = YtoTileY(clipBounds.y);
   tymax = YtoTileY(clipBounds.y + clipBounds.height - 1);
   AffineTransform transform = AffineTransform.getTranslateInstance(0 , 0 );
   offScrGraphics.drawRenderedImage(im.getSubImage(txmin, tymin,
clipBounds.width, clipBounds.height), transform);
   shape i;
   int num_annotations = list.size();
   for(int i1 = 0; i1 < num_annotations; i1++) {
      i = (shape)list.get(i1);
      i.paint(offScrGraphics);
   }
   for (tj = tymin; tj <= tymax; tj++) {
      for (ti = txmin; ti <= txmax; ti++) {
         AffineTransform transform1 =
AffineTransform.getTranslateInstance(0 , 0 );
         g2D.drawRenderedImage(offScrTile.getSubImage(ti*tileWidth ,
tj*tileHeight, tileWidth , tileHeight), transform1);
      }
   }
}

------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder
<http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com> - Free,
easy-to-use web site design software

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to