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

mouseWheel has no effect without vertical scrollbar

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7
    • Fix Version/s: tbd
    • Component/s: client-libs
    • Labels:

      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;
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              vdyakov Victor Dyakov
              Reporter:
              alexp Alexander Potochkin (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: