FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Windows 7 Ultimate 64 bit SP1
EXTRA RELEVANT SYSTEM CONFIGURATION :
Use a mouse that has more than 3 buttons, i.e. like the Microsoft Intellimouse.
The MS drivers are correctly installed for that mouse, and all buttons are recognized properly by the OS.
A DESCRIPTION OF THE PROBLEM :
MouseDragged events are not generated when using extra mouse buttons (i.e. 4, 5, 6) on a component that is part of a JSplitPane.
When dragging with mouse button (1,2,3), we can see MouseDragged events.
But, when dragging with extended mouse buttons (4,5,6), no dragged events are fired, even though MousePressed and MouseReleased are.
Note that dragging with the extended mouse buttons on a normal JPanel that is not part of a JSplitPane hierarchy produces the drag event correctly for button 4,5,6.
So, it looks like that
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the attached Swing application
2. Using mouse button 4, drag the mouse on the top gray area
3. Observe the console with java.awt.event.MouseEvent[MOUSE_DRAGGED events
4. Using mouse button 4, drag the mouse on the yellow area (which is part of the JSplitPane), observe that the console does not show any drag events.
This is problematic since our application needs to listen for drag events for extended buttons on components that are part of a JSplitPane.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
areExtraMouseButtonsEnabled=true
numberOfButtons=5
Observe the console with java.awt.event.MouseEvent[MOUSE_DRAGGED events when dragging with mouse button 4 over the yellow area (i.e. inside the JSplitPane)
ACTUAL -
areExtraMouseButtonsEnabled=true
numberOfButtons=5
No drag events are generated when dragging with mouse button 4 over the yellow area (i.e. inside the JSplitPane)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
-----------MouseApp.java------------------
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.MouseInfo;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
public class MouseApp {
public static void main(String[] args)
{
SwingUtilities.invokeLater( () -> {
buildTestApp();
});
}
private static void buildTestApp() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
boolean areExtraMouseButtonsEnabled = Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
System.err.println("areExtraMouseButtonsEnabled=" + areExtraMouseButtonsEnabled);
int numberOfButtons = MouseInfo.getNumberOfButtons();
System.err.println("numberOfButtons=" + numberOfButtons);
Toolkit.getDefaultToolkit().addAWTEventListener(
new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
System.err.println(event);
}
},
MouseEvent.MOUSE_EVENT_MASK |
MouseEvent.MOUSE_MOTION_EVENT_MASK |
MouseEvent.MOUSE_WHEEL_EVENT_MASK);
JPanel container = new JPanel(new BorderLayout());
JLabel label = new JLabel("Mouse Button 4 drag DOES NOT WORK here !");
label.setFont(label.getFont().deriveFont(35f));
JPanel problematicArea = new JPanel();
problematicArea.setLayout(new BorderLayout());
problematicArea.add(label, BorderLayout.CENTER);
problematicArea.setBackground(Color.yellow);
JLabel topLabel = new JLabel("Mouse Button 4 drag works here");
topLabel.setFont(topLabel.getFont().deriveFont(48f));
topLabel.setHorizontalTextPosition(SwingConstants.CENTER);
JSplitPane splitPane = new JSplitPane();
splitPane.setRightComponent(problematicArea);
splitPane.setLeftComponent(new JButton("Bro"));
container.add(splitPane, BorderLayout.CENTER);
container.add(topLabel, BorderLayout.NORTH);
f.setContentPane(container);
f.setSize(1024, 768);
f.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
We installed our own custom event queue, and intercepting mouse dragged events at that level for all mouse buttons.
This is far from being ideal since the source of the event is not correct (i.e. the source is the frame itself instead of being the component itself)