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.
|