-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
mantis
-
sparc
-
solaris_2.5
-
Verified
Name: apR10100 Date: 02/06/2002
Methods:
Frame.setIconImage incorrectly and
inconsistently handles null as parameter.
JDK1.4 spec states:
------------------
public Image getIconImage()
Gets the image to be displayed in the minimized icon for this frame.
Returns:
the icon image for this frame, or null if this frame doesn't have an icon image.
...
public void setIconImage(Image image)
Sets the image to be displayed in the minimized icon for this frame. Not
all platforms support the concept of minimizing a window.
Parameters:
image - the icon image to be displayed. If this parameter is null then the
icon image is set to the default image, which may vary with platform.
--------------------------------------------------------------------------------
According to this, setIconImage should accept null without
Exception and getIconImage() should return !null after
setIconImage(null) call. Behaviour of JDK1.4 is inconsistent
between solaris/windows and getIconImage() may return null
after setIconImage(null) call. Please, see the test example,
demonstrating this behaviour:
------ TestImage.java
import java.awt.*;
public class TestImage {
public static void main (String [] args) {
Frame f = new Frame();
f.show();
try {
f.setIconImage(null);
System.out.println("Set image to: '"+f.getIconImage()+"'");
} catch (NullPointerException npe) {
npe.printStackTrace();
} finally {
f.dispose();
}
}
}
------ Output solaris
3,~/tmp;
/set/java/jdk1.4/solaris/bin/java TestImage
java.lang.NullPointerException
at sun.awt.motif.MFramePeer.setIconImage(MFramePeer.java:98)
at java.awt.Frame.setIconImage(Frame.java:539)
at TestImage.main(TestImage.java:11)
3,~/tmp;
------ Output windows
Z:\tmp>C:\jdk1.4\bin\java.exe TestImage
Set image to: 'null'
Z:\tmp>
------
======================================================================
- relates to
-
JDK-4633899 Frame.setIconImage() contradicts to getIconImage() in case of null arg
- Closed