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

High contrast colour scheme fails to be applied to JFormattedTextField

XMLWordPrintable

    • b124
    • generic
    • windows

      SYNOPSIS
      --------
      High contrast colour scheme fails to be applied to JFormattedTextField

      OPERATING SYSTEM
      ----------------
      Windows XP

      FULL JDK VERSION
      ----------------
      JDK 7 (tested with b147)
      Also reproducible with Java 6

      PROBLEM DESCRIPTION from LICENSEE
      ---------------------------------
      When switching from a normal colour scheme to a high contrast colour scheme, all components of a running Java application's GUI should also change (when using the Windows L&F).

      Unlike other fields, which behave as expected, we have found that JFormattedTextField objects do not reflect the change in colour scheme until the Java application is restarted.

      The attached images illustrate the problem (1.png, 2.png, 3.png):

      1. Under normal colour scheme
      2. After switching to high contrast colour scheme (unexpected behaviour
         circled in red)
      3. After restarting under high contrast colour scheme (all fields appear
         in high contrast as expected)

      STEPS TO REPRODUCE
      ------------------
      1. Switch to "Windows Classic" style (Display Properties -> Appearance
         -> Windows and Buttons -> Windows Classic Style)
      2. Compile and run the attached testcase (ContrastCheck.java)
      3. Switch to a high contrast colour scheme (e.g. Display Properties ->
         Appearance -> Color Scheme -> High Contrast #1)

      Observed Result
      ---------------
      The high contrast colour scheme is not applied to 'JFormattedTextField' field (with value "5678910").

      Expected Result
      ---------------
      The high contrast colour scheme should be applied to all the fields.

      TESTCASE
      --------
      import java.awt.*;
      import java.text.*;
      import javax.swing.*;

      public class ContrastCheck {
          public static void main(String[] args) throws Exception {
              UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

              JFrame frame = new JFrame();
              frame.setSize(200, 100);
              frame.setDefaultLookAndFeelDecorated(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              Container content = frame.getContentPane();
              content.setLayout(new FlowLayout());
              content.add(new JButton("Button 1"));
              content.add(new JTextField("12345"));

              NumberFormat format = NumberFormat.getIntegerInstance();
              format.setMaximumIntegerDigits(5);
              JFormattedTextField formatted = new JFormattedTextField(format);
              formatted.setText("678910");
              content.add(formatted);
              frame.setVisible( true );
          }
      }

            rchamyal Rajeev Chamyal (Inactive)
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: