Hi,

horizontal scrolling in a JScrollPane does not work with a touchpad
with Metal and Nimbus Look & Feel  when both scrollbars are visible.
It does work with Aqua.

This little example demonstrates the problem:

import javax.swing.*;

public class TestTreeScrolling {
    public static void main(String[] args) throws Exception {
        for (UIManager.LookAndFeelInfo info :
UIManager.getInstalledLookAndFeels()) {
            if (info.getName().startsWith("Nimbus")) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
        final JFrame frame = new
JFrame(TestTreeScrolling.class.getSimpleName());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final JScrollPane scrollPane = new JScrollPane(new JTree());
        
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
        frame.getContentPane().add(scrollPane);
        frame.pack();
        frame.setVisible(true);
    }
}

Expand the tree a bit and resize the window so that both scrollbars
are visible. Making a horizontal scroll gesture on the touchpad
results in vertical scrolling.

Tested systematically with JDKs 6_51 and 8_11 but observed with all
production releases of 8 before as well.

Is this a known bug?

Is there a known workaround (hacking the Look & Feel is also an option
because we override it in our application anyway)? There must be as
IntelliJ Idea does not have this problem and they are not using Aqua
but I have failed to find it in their code.

Does it make sense to file a bug report and if so where?

Best,

Robert

Reply via email to