JDK-6911375 : mouseWheel has no effect without vertical scrollbar
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2009-12-17
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
The issue came up in Sun's developer forum:

http://forums.sun.com/thread.jspa?threadID=5420234&tstart=0

below is a runnable example 

To reproduce
- click into the list
- press page-down to verify scrolling by keyboard
- move the mousewheel: nothing happens - expected behaviour: scroll

the reason this happens is that the mouseWheelListener in BasicScrollPaneUI simply backs out if there is no scrollbar. Should take over instead, just as the scroll actions do always.

import javax.swing.*;

public class ScrollPaneActions extends JFrame {

    public static void main(String[] args) {
        ScrollPaneActions test = new ScrollPaneActions();
        try {
            test.interactiveScrollable();
        } catch (Exception e) {
            e.printStackTrace();
        }
        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        test.pack();
        test.setVisible(true);
    }


    public void interactiveScrollable() {
        JList list = new JList(createListModel());
        // disable list bindings
        list.getInputMap().getParent().clear();
        JScrollPane scrollPane = new JScrollPane(list);

        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        add(scrollPane);
    }

    private static ListModel createListModel() {
        DefaultListModel model = new DefaultListModel();
        for (int i = 0; i < 100; i++) {
            model.addElement("element " + i);
        }
        return model;
    }
}

Comments
- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

WORK AROUND The workaroun is provided here: http://forums.sun.com/thread.jspa?threadID=5420234&tstart=0
17-12-2009

EVALUATION BasicScrollPaneUI.Handler.mouseWheelMoved() skips the mouse wheel events when the scrollbar is not visible // find which scrollbar to scroll, or return if none if (toScroll == null || !toScroll.isVisible()) { toScroll = scrollpane.getHorizontalScrollBar(); if (toScroll == null || !toScroll.isVisible()) { return; } orientation = SwingConstants.HORIZONTAL; }
17-12-2009