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

SynthSliderUI.uninstallDefaults() is not called when UI is uninstalled

XMLWordPrintable

    • b86
    • generic
    • generic

      JDK: 7b78+
      Platform: All

      The following method of the class javax.swing.plaf.synth.SynthSliderUI

      protected void uninstallDefaults()
         Uninstalls default setting. This method is called when a LookAndFeel is uninstalled.


      is not called as expected. Please see the following code sample:

      ---------------------------------------------------------------------------------------
      import javax.swing.*;
      import javax.swing.plaf.synth.SynthLookAndFeel;
      import javax.swing.plaf.synth.SynthSliderUI;

      public class Test {
          
          public static void main(String[] args) throws Exception {
              SwingUtilities.invokeAndWait(new Runnable() {
                  @Override
                  public void run() {
                      doTheTest();
                  }
              });
          }

          private static void doTheTest() {
              try {
                  UIManager.setLookAndFeel(new SynthLookAndFeel());
              } catch (UnsupportedLookAndFeelException e) {
                  throw new RuntimeException(e);
              }
              class _SynthSliderUI extends SynthSliderUI {
                  protected _SynthSliderUI(JSlider c) { super(c); }
                  @Override protected void installDefaults(JSlider slider) {
                      System.out.println("installDefaults");
                      super.installDefaults(slider);
                  }

                  @Override protected void installListeners(JSlider slider) {
                      System.out.println("installListeners");
                      super.installListeners(slider);
                  }

                  @Override protected void uninstallDefaults() {
                      System.out.println("uninstallDefaults");
                      super.uninstallDefaults();
                  }

                  @Override protected void uninstallListeners(JSlider slider) {
                      System.out.println("uninstallListeners");
                      super.uninstallListeners(slider);
                  }
              }
              JSlider slider = new JSlider();
              _SynthSliderUI ui = new _SynthSliderUI(slider);
              slider.setUI(ui);
              slider.setUI(null);
          }
      }
      ---------------------------------------------------------------------------------------

      The output will be:

      installDefaults
      installListeners
      uninstallListeners

            rupashka Pavel Porvatov (Inactive)
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: