JDK-4250200 : Windows look-and-feel should track dynamic changes in users's desktop
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95,windows_nt
  • CPU: x86
  • Submitted: 1999-06-28
  • Updated: 2001-06-26
  • Resolved: 2001-06-26
Related Reports
Duplicate :  
Duplicate :  
Description

Name: et89391			Date: 06/28/99


There are two problems with the color of the default content pane of a JFrame.  I've included a small sample program to illustrate the problems.  I'm using Win95 with JDK v1.1.7B and Swing v1.1.1B1.  This problem also occurs under JDK v1.2.



Problem 1
---------
When using the Window's LaF, the color of a JFrame's content pane is always the same color as the "3D Objects" item specified in the Win95 desktop properties.  Instead, the content pane *should* be the color of the "Window" item in the Win95 desktop properties, not the "3D Objects" item.  Do this:

1. Right-click on the Win95 desktop, select the "Properties" menu option.  Now select the "Appearance" tab.  Change the background of the "3D Objects" item to yellow (for example).  Now change the color of the "Window" item to red.  Press the "OK" button to dismiss the dialog.

2. Now run the sample program below.  Notice that the content pane of the JFrame is yellow (i.e., the color of the "3D Objects" item), not red (i.e., the color of the "Window" item).

3. End the program.

4. Now uncomment the line in the program that changes the background color of the content pane to SystemColor.window and re-run the program.  Notice that the content pane is now red and is consistent with the "Window" color specified in the Win95 desktop properties.

The bug here is that it should not be necessary to explicitly set the background color of the content pane.  It should default to the color in SystemColor.window.



Problem 2 (continued from Problem 1)
------------------------------------
The color of a JFrame?s content pane does not change dynamically when the user changes the color of the ?Window? item (or even the ?3D Objects? item) in the Win95 desktop properties.  As I mentioned above, the color of the content pane should be tied to the ?Window? item, not the ?3D Objects? item.  Even though the content pane?s color is erroneously tied to the ?3D Objects? item, it should be the case that when a user changes the ?3D Objects? color in the Win95 desktop settings, the color of the content pane should automatically be updated.  After following steps 1-4 above, do this:

5. Right-click on the Win95 desktop, select the "Properties" menu option.  Now select the "Appearance" tab.  Change the background of the "3D Objects" item to something other than yellow -- let's say it's changed to green.  Press the "OK" button to dismiss the dialog.

The bug is that the JFrame's content pane does not change to green.  You may notice that any non-Java application windows *do* change.  Of course, once ?Problem 1? is fixed, you would change the ?Window? item, not the ?3D Objects? item.  I know there is some WM_* Windows message you can listen for to let you know when the system colors change.

Here's the sample program...


import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

public class Tester {
   private static JFrame frame = new JFrame("Tester");

   public static void main(String[] args) {
      try {
         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
         SwingUtilities.updateComponentTreeUI(frame);
      }
      catch(Exception e) {
         System.err.println("Error setting Windows LaF..." + e);
         System.exit(1);
      }

      frame.setBounds(70, 50, 400, 600);
      frame.setVisible(true);
      
      System.out.println("The window color is: R="     +
                         SystemColor.window.getRed()   + " G=" +
                         SystemColor.window.getGreen() + " B=" +
                         SystemColor.window.getBlue());
      
      //frame.getContentPane().setBackground(SystemColor.window);

      frame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent evt) {
            evt.getWindow().dispose();
            System.exit(0);
         }
      });
   }
}
(Review ID: 54919) 
======================================================================

Comments
EVALUATION Well, the content area inside a JFrame/JDialog is really just a panel by default. And, if you look at most of the Windows native applications, panels are the color of the controls ("3D objects"). The "window" color is instead applied to app "work" areas, such as the background behind the text in Notepad. Therefore, I believe the current content area panel color ("3D objects") is correct. As for problem#2 (dynamic updates), we are planning to fix that for merlin as part of the windows2000 project. amy.fowler@Eng 2000-03-16 amy.fowler@Eng 2000-03-16 The dynamic update was done as part of 4290973, I'm closing this out as a duplicate. scott.violet@eng 2001-06-26
16-03-2000