JDK-6425049 : win.frame.captionButtonWidth desktop property is not updated on system preference change
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: generic
  • Submitted: 2006-05-12
  • Updated: 2011-01-19
  • Resolved: 2007-06-09
Related Reports
Relates :  
Relates :  
Description
1. Run Test on windows.
2. Press "dump properties" button
3. Change system preferences for the frame height
(Control Panel -> Display Properties -> Appearance tab -> Advanced button -> Active Title Bar)
4. Press "dump properties" button again.
5. Please note that the value for win.frame.captionButtonWidth is not updated.

6. Close and run the applicaton again.
7. Press "dump properties" button.
8. The values are correct now.

--- Test.java
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Test {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        JButton button = new JButton("dump properties");
        button.addActionListener(
            new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    System.out.println("win.frame.captionButtonWidth "
                        + Toolkit.getDefaultToolkit().getDesktopProperty("win.frame.captionButtonWidth")
                        + "\nwin.frame.captionButtonHeight " 
                        + Toolkit.getDefaultToolkit().getDesktopProperty("win.frame.captionButtonHeight"));
                }
                
            });

        frame.add(button);
        frame.pack();
        frame.setVisible(true);
    }
}
---
After running the test some more on XP it seems that changing system
preferences while the app is running causes
win.frame.captionButtonWidth to pick up the previous correct value.

Running test on Vista b5381 looks much worse. win.frame.captionButtonWidth does not seem to pick up the right value ever.
After the system preference is changed win.frame.captionButtonWidth returns the original value all the time even if the app is restarted.

Comments
EVALUATION After running the test on Vista RTM the test passed. In other words, the win.frame.captionButtonWidth property always returns the latest value. So I'm closing the bug as non-reproducible anymore. Feel free to reopen the bug if it still occurs with Vista RTM.
09-06-2007

EVALUATION It seems like changing system preferences works better on vista build 5483 than on 5381. At least, the testcase from description section always passes in my environment.
28-07-2006

EVALUATION I could see the problem with native application on XP theme, Vista theme only. The function SystemParametersInfo returns NONCLIENTMETRICS structure. Values of the members iCaptionWidth & iCaptionHeight are kept the same on Vista and iCaptionWidth isn't updated correctly on XP.
15-05-2006

EVALUATION for some reasons I was able to reproduce the problem jsut couple times :( Usually the test worsk well. We do use SystemParametersInfo() to get new values of these properties. Note that it return both width and height in the same tiome, so it do not think that we miss some notifications about their changes (at least on XP). Most likely some time this method return incorrect values :(
12-05-2006