On Tue, 5 Dec 2023 14:09:42 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

> > > if the URL is invalid, the image isn't loaded
> > 
> > 
> > As per your change, if URL is invalid ie url = null, image is not loaded 
> > but `loadedImage` is set to true so it will not give another chance to load 
> > the URL again via `CSS.getURL` just in case user decides to call setBase 
> > with a valid URL (after finding `getImage `returning null)
> 
> Exactly! The image is **never** given a chance to load for a second time.
> 
> It is how the code has always worked.
>
But it can be a bug in the code that it never gave a chance second time..I 
think it should get a chance to reload the URL again in case it is invalid the 
1st time so I guess the change should be the one where if url is invalid, 
`loadedImage ` should not be set and it will need a relook at the url (to be 
set by user)

                  

if (!loadedImage) {
                        URL url = CSS.getURL(base, svalue);
                        if (url != null) {
                            image = new ImageIcon();
                            Image tmpImg = 
Toolkit.getDefaultToolkit().createImage(url);
                            if (tmpImg != null) {
                                image.setImage(tmpImg);
                            }
                            loadedImage = true;
                        }
                    }

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

PR Comment: https://git.openjdk.org/jdk/pull/16917#issuecomment-1840893445

Reply via email to