JDK-6425606 : PIT: Child dialog inherits the wrong icon from the parent frame if the parent is LAF decorated
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-05-14
  • Updated: 2010-04-03
  • Resolved: 2006-07-11
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
I have created a JFrame after calling setDefaultLookAndFeelDecorated(true). This turns off the native decoration and uses the decoration provided by the default look and feel. I have called JFrame.setIconImages() with 2 images (duke.gif and sun.gif). I expect the JFrame to pick up the right one depending on the image dimensions. I see 2 issues here - 

1. JFrame picks up duke.gif as the icon on the title bar. But when I maximize the frame, I could see sun.gif appearing on the title bar momentarily. When I use the native decoration for the JFrame, it picks up sun.gif and not duke.gif. Hence LAF decoration is not consistant with native decoration with respect to choosing the right icon.

2. I am creating a child dialog and showing it on the screen. The child dialog is supposed to inherit the icon from the parent. In this case, I expect the child dialog to show duke icon on the title bar. But it shows the sun logo icon which is not being used currently by the parent frame. This is confusing. 

Frame and Dialog must be consistant in what icon they use for the title bar. I think the default look & feel decoration should also be consistant with native decoration with respect to the title bar icon, as long as the platform is same. 

This is reproducible only on the AWT PIT build for b85. This is a new feature introduced in b85 PIT. The above behaviors are noticed on WinXP. On the latest promoted build, we could pass only one image and hence this behavior is not seen. Hence this is specific to the PIT build.

I have attached a sample test. Execute the sample test. You would see a duke image on the title bar. Maximize the frame. You would see sun logo icon momentarily when the frame maximizes. Click on the button. A dialog will open up. If the dialog's icon does not match with Frame's icon, the bug is reproduced.

Comments
EVALUATION I filed 6447692 (Undecorated windows flash native decorations when being maximized) for issue #1.
11-07-2006

EVALUATION Other than a brief flash of the native decorations when maximizing a client-decorated frame, I don't think there's a bug here. The key is that the ideal icon size is different between the native or client-drawn window decorations, and therefore a different graphic is chosen. This is exactly how the setIconImages() API is designed to work. Ordinarily several sizes of the same graphic are used, and I think the use of different graphics is causing some confusion. My response to the reported problems are as follows: 1a) When maximizing a client-decorated JFrame, it's not only the icon which changes but the JFrame changes to using the native decorations for the transition between the starting size and maximized size. Intersting behavior, though also present in 1.5. 1b) As you note, a different icon size is chosen depending on native or client-painted decorations. This behavior is as expected. 2) The JFrame and the Dialog use a different icon for the same reason as above: one is using client decorations, the other is using native decorations. The fact the the Dialog is not using the default icon indicates that the Dialog is, in fact, inheriting the icon(s) from the parent JFrame. You can also confirm this by changing the JFrame to also use native decorations. In this case, the JFrame and Dialog use the same icon. I will be closing this out as Not A Bug.
30-05-2006

EVALUATION Redispatching this bug because most of modifications should be made in swing
24-05-2006

EVALUATION The bug is caused by fix for 6339074. JFrame's decorations are painted by swing if it's LAF decorated. Swing gets image for LAF decorations using Frame.getIconImage() method, that returns first of the images.
17-05-2006