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

mouseWheel has no effect without vertical scrollbar

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 19
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b13
    • CPU:
      generic
    • OS:
      generic

      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

          Issue Links

            Activity

              People

              Assignee:
              psadhukhan Prasanta Sadhukhan
              Reporter:
              alexp Alexander Potochkin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: