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

BasicListUI.uninstallDefaults method does not set list properties to null

XMLWordPrintable

    • beta2
    • sparc
    • solaris_2.6



      Name: nkR10003 Date: 10/23/2000



      JavaDoc comments for BasicListUI.uninstallDefaults states:
      " Set the JList properties that haven't been explicitly overridden to
      null." Actually JList properties such as (selection)background,
      (selection)foreground and font are not null after uninstallUI
      (uninstallDefaults) invocation.

      Example below demonstrates this problem:
      ------------------example--------------------
      //test.java
      import javax.swing.plaf.basic.*;
      import javax.swing.*;
      public class test {
          public static void main(String[] args) {
              BasicListUI ui = new BasicListUI();
              JList list = new JList();
              list.setUI(ui);
              ui.uninstallUI(list);
              
              if (!(list.getBackground() == null
                      && list.getSelectionBackground() == null
                      && list.getForeground() == null
                      && list.getSelectionForeground() == null
                      && list.getFont() == null)) {
                  System.out.println("background: " + list.getBackground());
                  System.out.println("foreground: " + list.getForeground());
                  System.out.println("selection background: " + list.getSelectionBackground());
                  System.out.println("selection foreground: " + list.getSelectionForeground());
                  System.out.println("font: " + list.getFont());
                  System.out.println("Test Failed");
                  System.out.println("===========");
                  System.exit(1);
              }
              
              System.out.println("Test passed OK");
              System.out.println("==============");
          }
      }
      ----------------output:----------------------
      background: javax.swing.plaf.ColorUIResource[r=255,g=255,b=255]
      foreground: javax.swing.plaf.ColorUIResource[r=0,g=0,b=0]
      selection background: javax.swing.plaf.ColorUIResource[r=204,g=204,b=255]
      selection foreground: javax.swing.plaf.ColorUIResource[r=0,g=0,b=0]
      font: javax.swing.plaf.FontUIResource[family=dialog,name=Dialog,style=plain,size=12]
      Test Failed
      ===========
      ---------------------------------------------
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            knasunw Kna Kna (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: