JDK-6445278 : JDialog.setIconImage(s)() doesn't properly set the alt-tab icon on WinXP
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-06-29
  • Updated: 2014-05-06
  • Resolved: 2014-05-06
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Dialog and JDialog behave differently with respect to setting the icon used in the alt-tab listing on Windows XP.  This may also be true of other icon usages and/or other platforms.  For instance on WinXP, only the AWT Dialog appears in the task bar.

The included test demonstrates the problem.  A Dialog and JDialog are setup identically.  The icons are both set correctly in the title bars, however when you press alt-tab to switch between applications, you can see that the icon for the AWT Dialog is also the custom icon, but the JDialog's icon is still the default.

I believe this is limited to the case of dialogs with null owners - otherwise, the owning frames's icon is the only one in the alt-tab list.

This is a bug in new Mustang functionality - before Window.setIconImage() was added, there wasn't a way to set an icon directly on a (J)Dialog.

// Test showing that setIconImage() doesn't set the alt-tab icon for JDialog,
// yet does for Dialog
import java.awt.*;
import javax.swing.*;
import javax.imageio.*;
import java.io.*;

public class JDialogSetIconBug {
    public static void main(String[] args) {
        try {
            Dialog dialog = new Dialog((Frame)null, "AWT Dialog");
            JDialog jdialog = new JDialog((Frame)null, "JDialog");
            Image icon = ImageIO.read(new File("64x64.gif"));

            dialog.setBounds(10, 200, 100, 100);
            dialog.setIconImage(icon);

            jdialog.setBounds(200, 200, 100, 100);
            jdialog.setIconImage(icon);

            dialog.setVisible(true);
            jdialog.setVisible(true);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Comments
We don't have plans to fix it
06-05-2014

EVALUATION The 'ownerless JDialogs' are actually owned by hidden Frame. That frame has default java icon, so that icon is shown in the Windows Alt+Tab list. Gnome shows the icon for owned window if owner is hidden, so the bug is not reproducible on Solaris/Linux. Transferring the CR back to swing for additional investigation.
30-06-2006

EVALUATION I can reproduce this on XP, but not on Solaris 10 x86/GNOME. Because this appears to be platform-specific, I'm going to let AWT have the first look at this one.
30-06-2006