Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4091895

Closing a Frame with an icon prevents further use of icon

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4
    • client-libs
    • 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)
      ======================================================================

            Unassigned Unassigned
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: