-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.4
-
x86
-
windows_nt
Name: joT67522 Date: 11/11/97
Starting with 1.1.3 there was a new bug introduced with setIconImage() on Windows.
The bug is also present in the 1.1.4.
If you have a common image that you are using with all your Frames and then dispose
of one of those frames, further setIconImage()'s on new Frames fail. You just get the
default coffee cup icon.
I suspect you are doing something destructive to the image when the Frame is disposed.
It is not a problem with setIconImage itself because I can still use a different image successfully.
I tried creating a copy of the image and using the copy for each setIconimage() but the
only way to create a copy (that I know of) is createImage() and that creates a WOffscreenImage.
It doesn't appear that setIconImage works with those.
Here is a test program to demonstrate the problem:
contents of Test.java
=================================================================
// A simple test program to illustrate a setIconImage bug.
// If you have a common image that you are using with all your Frames
// and then dispose of one of those frames, further setIconImage()'s
// on new Frames fail. You just get the default coffee cup icon.
//
// To run the program you will need to have an icon image called
// "titlelogo.gif". The program creates 4 frames. After creating the
// second frame it dispose()'s it. The two subsequent frames don't
// have the correct window icon.
import java.awt.*;
public class Test
{
static Image image;
static public void main(String args[]) {
Test test = new Test();
test.doIt();
}
private void doIt() {
for (int i = 0; i < 4; i++) {
Frame f = new Frame();
if (image == null)
image = Toolkit.getDefaultToolkit().getImage("titlelogo.gif");
f.setIconImage(image);
f.setBounds(100, 100, 100, 100);
f.setVisible(true);
if (i == 1) {
f.dispose();
}
}
}
}
(Review ID: 19200)
======================================================================
- duplicates
-
JDK-4100793 Java 1.1.x on win32: frame dispose destroys shared icon resource
- Closed