On Tue, 15 Mar 2022 16:42:41 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> A small file from local storage loads fast enough. By the time you get to 
>> read status, load could complete.
>> 
>> For the url, do you use the same URL? If the connection can be established, 
>> it should load pretty fast too. However, if you need a proxy server to 
>> access the Internet but you won't provide one, it won't load as fast, nor 
>> will it report error fast enough.
>> 
>> Anyway, my example above confirms *it's possible the status remains 
>> `LOADING`*. But the image isn't loading, it will never load and its status 
>> will never change, so you have to amend the status to a correct one.
>
>> @aivanov-jdk , U r right, the status remains LOADING for url...... I was 
>> getting "ERRORED" because I was showing a message using 
>> `JOptionPane.showMessageDialog(null, "");` before setting ImageIcon.
> 
> Ah, with the message dialog shown there's enough time to complete loading the 
> image.

> N for current bug, where to change to change the status to "ABORTED"......?? 
> As I cannot change in ImageIcon class......

Why can't you change the status in `ImageIcon`? It's where you change it.


            loadStatus = mTracker.statusID(id, false);
            mTracker.removeImage(image, id);
            if (loadStatus & MediaTracker.LOADING != 0) {
                loadStatus = MediaTracker.ABORTED;
            }

The first two lines already exist, right after the catching 
`InterruptedException`. You just need to add the `if` block to amend the status.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7754

Reply via email to