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

Nimbus ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is never invoked

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7, 8, 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b124
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_04"
      Java(TM) SE Runtime Environment (build 1.7.0_04-b22)
      Java HotSpot(TM) Client VM (build 23.0-b21, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      this problem is platform independent

      A DESCRIPTION OF THE PROBLEM :
      Nimbus L&F gives three parameters defining enabled JScrollBar thumb painting methods: one for the thumb itself, one for the thumb pointed by the mouse (when mouse pointer is placed over it) and one for the dragged thumb (when mouse pointer is kept pressed over it).

      These parameters are:

      ScrollBar:ScrollBarThumb[Enabled].backgroundPainter
      ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter
      ScrollBar:ScrollBarThumb[Pressed].backgroundPainter

      and denotes the Painter<?> interface implementation objects with 4-parameters paint method, that have to be invoked for doing the right job.

      Unfortunately it looks that first painter is invoked for plain thumb and the second one is invoked for both: pointed and pressed thumbs -- in result the third method is never invoked.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The simplest way is to set those painters to nulls and see whether the JScrollBar thumb is painted or not.

      1. Set Nimbus L&F:
      UIManager.setLookAndFeel (new NimbusLookAndFeel ());

      2. Set ScrollBar painter:
      UIManager.getLookAndFeelDefaults().put ("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", null);

      3. Define the window with JScrollPane with JEditorPane containing any text.

      4. Just point and click the thumb to see that nothing happend when you pressed mouse over it.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The thumb should vanish after pressing the mouse over it (indicating that
      ScrollBar:ScrollBarThumb[Pressed].backgroundPainter is really invoked) and reappear when mouse button is released.

      You can compare this with setting
      UIManager.getLookAndFeelDefaults().put ("ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter", null);. It works properly -- when you move the mouse over the thumb it vanishes (but still operates, you can drag the invisible thumb). The thumb reappears when you move the mouse outside of its boundaries.
      ACTUAL -
      Nothing happens -- the thumb looks the same when both pointed and pressed.

      It can be interesting to note, that for JButtons all analogous painters are invoked correctly.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages apperaring.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      import javax.swing.UIManager.*;
      import javax.swing.plaf.nimbus.*;

      public class BugGenerator extends JDialog
      {

        public static void main (String[] args)
        {

          for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels ())
          {
            if ("Nimbus".equals (info.getName ()))
            {
              try
              {
                UIManager.setLookAndFeel (new NimbusLookAndFeel ());

                //just comment/uncomment these lines to see if the particular painter is invoked
                //UIManager.getLookAndFeelDefaults().put ("ScrollBar:ScrollBarThumb[Enabled].backgroundPainter", null);
                //UIManager.getLookAndFeelDefaults().put ("ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter", null);
                UIManager.getLookAndFeelDefaults().put ("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", null);
              }
              catch (Exception ex)
              {
              }
              break;
            }
          }

          new MyDialog ();

        } //main (String[])

      } //BugGenerator


      class MyDialog extends JDialog
      {

        private final String editpane_content = new String ("A\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM\nN\nO");

        public MyDialog ()
        {
          super ((JFrame)null, "Bug Generator", true);
          constructDialog ();
        } //MyDialog ()

        private void constructDialog ()
        {

          JEditorPane editpane = new JEditorPane ();
          editpane.setEditable (false);
          editpane.setText (editpane_content);
          editpane.setCaretPosition (0);

          JScrollPane scrollpane = new JScrollPane (editpane);

          this.add (scrollpane);

          this.setDefaultCloseOperation (DISPOSE_ON_CLOSE);
          this.setPreferredSize (new Dimension (200, 200));

          this.pack ();

          this.setResizable (false);
          this.setLocationRelativeTo (null);
          this.setVisible (true);

        } //constructDialog ()

      } //MyDialog

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The only workarounds is:

      not to use Nimbus

      or

      write own JScrollBar


      both are hardly acceptable.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aghaisas Ajit Ghaisas
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: