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

Win L&F: Bug 4174290 not fixed. Disabled JTextField background should be grey

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      1.2.1
    • Introduced In Version:
    • Resolved In Build:
      tiger
    • CPU:
      x86
    • OS:
      windows_nt, windows_2000

      Description



      Name: pa48320 Date: 06/24/2003

      Text field backgrounds should be coloured gray when fields are disabled. Currently the text itself is grayed out, but the background remains white. Often times, however, there is no text in the field so the user has no indication that the field is disabled.

      If you disable a Swing JTextField so that it is disabled and hence non-editable, it retains the same background colour as the editable version. This is not the way Swing's Windows L&F should behave.

      Under the Windows XP L&F 1.4.2 with "adjust for best appearance" set, the disabled field looks correct, but non-XP L&F retain this very confusing behaviour.

      To simulate the problem implement the following code:

      *****************************************************
      package pfstest;

      import javax.swing.*;
      import javax.swing.BoxLayout;
      import javax.swing.JFrame;
      import javax.swing.JTextField;
      import javax.swing.UIManager;

      public class GuiBug extends JFrame {

          JTextField enabled_and_editable;
          JTextField disabled;
          JTextField disabled_and_uneditable;
          JTextField uneditable;

          public static void main(String[] args) {
        try {
        UIManager.setLookAndFeel"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      //
                  UIManager.setLookAndFeel
                      ("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
      //
                  UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } catch (Throwable t) {
      t.printStackTrace();
        }
              GuiBug text = new GuiBug();
        text.show();
      }

      public GuiBug() {

        enabled_and_editable = new JTextField("Enabled and Editable");
      disabled = new JTextField("Disabled");
      disabled_and_uneditable =
                             new JTextField("Disabled and uneditable");
        uneditable = new JTextField("Uneditable");
        disabled.setEnabled(false);
        uneditable.setEditable(false);
        disabled_and_uneditable.setEnabled(false);
        disabled_and_uneditable.setEditable(false);

        Box b = new Box(BoxLayout.Y_AXIS);
        b.add(enabled_and_editable);
        b.add(Box.createVerticalStrut(10));
        b.add(disabled);
        b.add(Box.createVerticalStrut(10));
        b.add(uneditable);
        b.add(Box.createVerticalStrut(10));
        b.add(disabled_and_uneditable);
        b.add(Box.createVerticalStrut(10));

        getContentPane().add("Center", b);
        pack();
        }

      }
      *****************************************************

      Thus if one has an editable JTextField and one disables it (as a consequence of which it becomes non-editable) the background color should be different from an editable JTextField. So a UI would just need to disable a JTextField if it was in a group of components which was disabled (say they were grouped as one of several choices
      chosen using radio buttons). In other words there would be
      no need for a well-behaved UI to set it non-editable AND
      disable it for it to get the appropriate L&F under Windows.

      The 1.4.2. behavior seems to strenghthen the case that the look and feel (non-xp) is wrong? Obviously, under the XP look and feel the
      feeling is that "disabled" should display the same way as "disabled and uneditable", but they don't seem to be adhering to the same behaviour with non-XP look and feel - inconsistency? Shouldn't the equivalent Windows control when disabled have a background similar to the "disabled and uneditable"?




      Under 1.4.2, I noticed no difference. Here's the sample program output:



      Then I realized that I'd set my computer to "adjust for best performance". When
      I change it to "adjust for best appearance" and rerun the program I see (which
      is what my user was complaining that I should be doing and which started this
      thread):



      I guess I don't quite understand how the look and feel interacts with the OS's
      appearance / performance selection that I make.


      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              leifs Leif Samuelsson (Inactive)
              Reporter:
              pallenba Peter Allenbach (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: