JDK-4487750 : Strange mouse wheel/scrollbar behavior on Windows
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-08-03
  • Updated: 2024-04-02
Related Reports
Relates :  
Relates :  
Description
Run the attached test.  Rotate the mouse wheel while the cursor is over the Scrollbar, and the JScrollbar.

The components in the test are layed out in the Frame as follows:

[JScrollBar][Label][Scrollbar]

Though the wheel events are correctly delivered, when the mouse wheel is rotated when the cursor is over the JScrollBar, the Scrollbar (on the other side of the Frame) is adjusted.  Clearly, this is incorrect behavior.  It's as if a ScrollPane were added, instead of a Scrollbar.

After more experimentation, I learned that this is true if additional Swing components are added in the "middle" of the window - a JButton, for instance.  The problem goes away if another heavyweight component (such as a Button) are added.  The problems also disappear if the Scrollbar is the left-most Component in the Frame.

So, the following configurations yield broken behavior:

[JScrollBar][Label][Scrollbar]
[JScrollBar][JButton][Label][Scrollbar]

The following are okay:

[JScrollBar][Button][Label][Scrollbar]
[Scrollbar][Label][JScrollBar]

Comments
EVALUATION Bug in 1.4 feature. Commit to hopper, tiger. ###@###.### 2001-11-14 Because the bug involves mixing heavyweights and lightweights (highly discouraged), this doesn't have sufficient priority for fixing in hopper. ###@###.### 2002-04-16 It looks like Windows is "helping" us by sending some extra events behind the scenes. According to Spy++ and some extra debugging code in AWT, in this situation Windows is eating the WM_MOUSEWHEEL message, and then sending a SBM_SETSCROLLINFO to the Scrollbar. This explains both why we aren't getting MouseWheelEvents, and why the Scrollbar is scrolling when it shouldn't. Another point of interest - if the mouse is over a Component which has the focus, the problem occurs. If the focus is elsewhere, all is well. I found this to be true of Button and Checkbox. Given the relatively low usage of the Scrollbar component, and the liklihood that a kludgey fix will be required, I don't consider this a priority for Mantis. ###@###.### 2002-09-11
11-09-2002