6614972: JSlider value should not change on right-click
Summary: WindowsSliderUI won't use the right mouse button for change slider position
Reviewed-by: alexp
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Tue Apr 29 15:47:17 2008 +0400
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Tue Apr 29 17:48:01 2008 +0400
@@ -982,7 +982,7 @@
"LEFT", "positiveUnitIncrement",
"KP_LEFT", "positiveUnitIncrement",
}),
-
+ "Slider.onlyLeftMouseButtonDrag", Boolean.FALSE,
"Spinner.ancestorInputMap",
new UIDefaults.LazyInputMap(new Object[] {
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Tue Apr 29 15:47:17 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Tue Apr 29 17:48:01 2008 +0400
@@ -1364,6 +1364,7 @@
"LEFT", "positiveUnitIncrement",
"KP_LEFT", "positiveUnitIncrement",
}),
+ "Slider.onlyLeftMouseButtonDrag", Boolean.TRUE,
// *** Spinner
"Spinner.font", monospacedPlain12,
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Tue Apr 29 15:47:17 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Tue Apr 29 17:48:01 2008 +0400
@@ -1573,6 +1573,11 @@
// Clicked in the Thumb area?
if (thumbRect.contains(currentMouseX, currentMouseY)) {
+ if (UIManager.getBoolean("Slider.onlyLeftMouseButtonDrag")
+ && !SwingUtilities.isLeftMouseButton(e)) {
+ return;
+ }
+
switch (slider.getOrientation()) {
case JSlider.VERTICAL:
offset = currentMouseY - thumbRect.y;
@@ -1584,6 +1589,11 @@
isDragging = true;
return;
}
+
+ if (!SwingUtilities.isLeftMouseButton(e)) {
+ return;
+ }
+
isDragging = false;
slider.setValueIsAdjusting(true);