Check if image is loaded before drawing it



  • @Christoph-Hart It would be useful to get a check if the image is loaded or not in a panel before drawing it.

    When creating a panel you often have to create the paint routine before the images are downloaded. This creates an "Image xxx not found" error before you have the chance to repaint with the loaded image... Or is there already a trick like loading a dummy one?



  • I load the image inside the paint routine

    if (f.isFile())
    {
        this.loadImage(f.toString(File.FullPath), item.id);
        g.drawImage(item.id, a, 0, 0);
    }
    


  • @d-healey Oh that's a nice trick.
    For the moment I just used a dummy image that I replace once the download is done...



  • I should mention that I only call this paint routine once when the images are downloaded (or resynced) so there is no issue of files being repeatedly loaded. However if you do want to repaint more than once you could use an array to keep track of which files you've loaded or use a variable as a flag to indicate if all the image have aready been loaded.


Log in to reply
 

8
Online

1.3k
Users

4.1k
Topics

36.5k
Posts