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

Windows look-and-feel should track dynamic changes in users's desktop

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Duplicate
    • P4
    • None
    • 1.2.0
    • client-libs
    • x86
    • windows_95, windows_nt

    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)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              amfowler Anne Fowler (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: