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

Nested JScrollPanes don't scroll properly

XMLWordPrintable

    • generic, x86
    • generic, windows_xp

      JScrollPane consumes all mouseWheel events in all cases now, but it's not correct behaviour, for example if there is enough space for the view component (JScrollPane doesn't show scrollBars) JScrollPane shouldn't consume mouseWheelEvents and let outer JScrollPane be scrolled

      During meeting with customers in SPb guys from Intellij pointed to this problem

      Run the following test
      with help of mouse wheel scroll nested pane to the end
      keep scrolling

      Expected behaviour:
      if nested pane can't be scrolled any more, mouse wheel should start scrolling outer pane

      Current behavoiur:
      JScrollPane consumes mouseWheel events for any case
      (even if there is enough place for the view componen and it's can't be scrolled)

      import javax.swing.*;
      import java.awt.*;

      public class NestedScrollPane {
          public static void main(String[] args) throws Exception {
              final JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              JPanel panel = new JPanel();
              panel.setPreferredSize(new Dimension(0, 250));
              JScrollPane outer = new JScrollPane(panel);
              
              JButton b = new JButton("Hello");
              b.setPreferredSize(new Dimension(100, 100));
              JScrollPane inner = new JScrollPane(b);
              inner.setPreferredSize(new Dimension(100, 100));
              panel.add(inner);
              
              frame.add(outer);

              frame.setSize(200, 200);
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
          }
      }

            Unassigned Unassigned
            alexp Alexander Potochkin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: