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

Some swing components do not respect high-contrast setting on windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.4.1
    • client-libs
    • None
    • generic, x86
    • solaris_2.6, windows_2000, windows_xp

      Some swing components do not respect high-contrast setting on windows in regards
      to font size.

      For example, the font in JMenu is changed to larger one when the high-contrast setting on.

      However, JTextField, JComboBox do not change the font when the high-contrast setting is on.

      At the same time, JTree does change the font in 1.4 (but incorrectly, it clips text vertically). In 1.4.1 JTree doesn't change the font at all (like JTextField and JComboBox).

      It seems like all lightweights should change the fonts in when the high-contrast
      setting is on.

      Borland wants to claim section 508 compatibility in JBuilder. Hence, they need
      all lightweight components to inherit both the larger fonts and high-contrast colors from the platform when so configured.

      Below is the small test case that shows problems with different components.

      import java.awt.*;
      import javax.swing.*;
      import javax.swing.tree.*;
      import java.util.*;

      public class testframe {

          public static void main (String [] args) {
              JMenuBar jm = new JMenuBar();
              jm.add(new JMenu("menu1"));
              jm.add(new JMenu("menu2"));
              
              JFrame jf = new JFrame();
              jf.setSize(500, 500);
              jf.getContentPane().setLayout(new GridLayout(3, 2));
              DefaultMutableTreeNode node = new DefaultMutableTreeNode("SampleTreeNode", true);
              JTree tree = new JTree(node);
              tree.setRowHeight(20);

              String[] sa = {"item 1", "item2"};
              JComboBox jc1 = new JComboBox(sa);
              jc1.setEditable(true);
              jf.getContentPane().add(jc1);


              jf.getContentPane().add(new JTextField("Sample text field"));
              jf.getContentPane().add(tree);
              jf.setJMenuBar(jm);
              jf.setVisible(true);
          }

      }

      to reproduce please run the following in the high contrast mode on win 2000:

      1) jdk1.4.1\bin\java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel testframe

      This will result only in JMenu resized

      2) jdk1.4\bin\java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel testframe

      This will result in JMenu resized and JTree resized (but incorrectly)

      Both times, JTextField and JComboBox have font unchanged by the high contrast
      setting.

      The same situation is observed in metal L&F with swing.useSystemFontSettings=true

            svioletsunw Scott Violet (Inactive)
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: