JDK-8186522 : MacBook "two finger" right click causes JScrollPane to scroll
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u131
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: x86_64
  • Submitted: 2017-08-15
  • Updated: 2017-10-11
  • Resolved: 2017-10-11
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
OS X 10.11.6

A DESCRIPTION OF THE PROBLEM :
MacBooks (and maybe other Apple hardware) has a touchpad where you can use a two finger (gesture) to scroll, and when clicking with two fingers it acts as a "right click". The same stands for two finger tapping.

From version (at least) 1.8.131 up to 1.8.141 (or maybe higher) there is a bug in the JRE where using the two finger click (or tap) after scrolling with two fingers fails: instead of right click action first a scroll action were fired, than the right click.

This is a very annoying bug, as on MacBook users likely to use two-finger scroll with two-finger right-click. But instead of selecting the clicked item, the tree is scrolled, and an item above or below is selected instead.

Scroll is observer in both up and down and some times in the horizontal directions as well. 

REGRESSION.  Last worked in version 8u121

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Add a JScrollPanel, add a JTree with a good amount of items.
Scroll with two fingers, click on two fingers.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No scroll before right-click event arrives.
ACTUAL -
Tree will likely to jump one item up or down.

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
import java.util.UUID;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;

public class ScrollTest extends JDialog implements TreeSelectionListener
{
    public static void main(String[] args)
    {
        ScrollTest dialog = new ScrollTest();
        dialog.setModal(true);
        dialog.pack();
        dialog.setVisible(true);
        System.exit(0);
    }

    public ScrollTest()
    {
        DefaultMutableTreeNode top =
            new DefaultMutableTreeNode("The Java Series");
        createNodes(top);

        JTree tree = new JTree(top);
        for (int i = 0; i < tree.getRowCount(); i++) {
            tree.expandRow(i);
        }

        JScrollPane treeView = new JScrollPane(tree);

        this.add(treeView);
    }

    private void createNodes(DefaultMutableTreeNode top)
    {
        for (int c = 0; c < 5; c++)
        {
            DefaultMutableTreeNode category;
            category = new DefaultMutableTreeNode(
                "Cat #" + c + " - Books for Java Programmers");
            top.add(category);

            for (int n = 0; n < 30; n++)
            {
                DefaultMutableTreeNode book =
                    new DefaultMutableTreeNode(
                        "Node #" + n + " " + UUID.randomUUID().toString());
                category.add(book);
            }
        }
    }

    @Override
    public void valueChanged(TreeSelectionEvent e)
    {
        System.out.println(e.getPath());
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use an external mouse.


Comments
Closing this as duplicate of JDK-8173876 which has a fix for 8u152. Submitter has confirmed back stating, "I have tried with my synthesized test, I can confirm that with JDK 8u152 (early access build) the problem disappeared."
11-10-2017

Written back to the submitter requesting status with JDK 8u152 and 9 ea builds where the issue is likely resolved. http://jdk.java.net/8/ http://jdk.java.net/9/
13-09-2017

Could be a duplicate of JDK-8173876
24-08-2017