JDK-6933784 : NIMBUS: ImageView getNoImageIcon and getLoadingImageIcon returns nulls instead of an icon
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-03-10
  • Updated: 2017-05-19
  • Resolved: 2010-04-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u21Fixed 7 b89Fixed OpenJDK6Fixed
Description
Consider this small program:
import java.awt.*;
import java.io.*;
import java.io.PrintWriter;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;

public class test
{
         public static void main (String args[])
         {
                String test="<HTML><TITLE>Test</TITLE><BODY><IMG id=test></BODY></HTML>";
                HTMLEditorKit c = new HTMLEditorKit();
                HTMLDocument doc = new HTMLDocument();

                  try {
                             c.read(new StringReader(test), doc, 0);
                      } catch (IOException e) {
                             System.out.println("Failed Unexpected IOException " + e);
                      } catch (BadLocationException e) {
                             System.out.println("Failed Unexpected BadLocationException " + e);
                      } catch (RuntimeException e) {
                             System.out.println("Failed Unexpected RuntimeException " + e);
                      }
                  Element elem = doc.getElement("test");
                  ImageView iv = new ImageView(elem);

                  if (!(iv.getLoadingImageIcon()!=null)){
                      System.out.println(" Failed Method getLoadingImageIcon.");
                  }else {
                      System.out.println(" Passed Method getLoadingImageIcon.");}
                  if (!(iv.getNoImageIcon()!=null)){
                      System.out.println(" Failed Method getNoImageIcon.");
                      }else {
                  System.out.println(" Passed Method getNoImageIcon."); }

        }
}


When run with nimbus l&f it gives wrong results:

/export/jdk/jdk1.6.0_18/bin/java -cp . -Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel test
Failed Method getLoadingImageIcon.
Failed Method getNoImageIcon.

/export/jdk/jdk1.6.0_10/bin/java -cp . test
Passed Method getLoadingImageIcon.
Passed Method getNoImageIcon.


According to http://java.sun.com/javase/6/docs/api/javax/swing/text/html/ImageView.html
getNoImageIcon()
          Returns the icon to use if the image couldn't be found.
getLoadingImageIcon()
          Returns the icon to use while in the process of loading the image.

Comments
EVALUATION We should add "html.pendingImage" and "html.missingImage" images into UIDefaults map for Synth LaF. They are missed because Synth LaF doesn't use UIDefaults from the BasicLookAndFeel class
15-03-2010