When playing with some apps I noticed that our conditions in
BasicButtonListener.mouseEntered() where not quite right. Fixed by the
attached patch.

2006-05-04  Roman Kennke <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicButtonListener.java
        (mouseEntered): Fixed conditions for changing states.

/Roman
Index: javax/swing/plaf/basic/BasicButtonListener.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicButtonListener.java,v
retrieving revision 1.12
diff -u -1 -0 -r1.12 BasicButtonListener.java
--- javax/swing/plaf/basic/BasicButtonListener.java	18 Oct 2005 22:10:32 -0000	1.12
+++ javax/swing/plaf/basic/BasicButtonListener.java	4 May 2006 14:40:29 -0000
@@ -45,20 +45,21 @@
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
 import javax.swing.AbstractAction;
 import javax.swing.AbstractButton;
 import javax.swing.ButtonModel;
 import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
 public class BasicButtonListener implements MouseListener, MouseMotionListener,
   FocusListener, ChangeListener, PropertyChangeListener
 {
   public BasicButtonListener(AbstractButton b)
   {
     // Do nothing here.
   }
@@ -197,28 +198,26 @@
    * button is not held down, this enter event will also disarm the model.
    *
    * @param e The mouse enter event to accept
    */
   public void mouseEntered(MouseEvent e)
   {
     if (e.getSource() instanceof AbstractButton)
       {
         AbstractButton button = (AbstractButton) e.getSource();
         ButtonModel model = button.getModel();
-        if (button.isRolloverEnabled())
+        if (button.isRolloverEnabled()
+            && ! SwingUtilities.isLeftMouseButton(e))
           model.setRollover(true);
-        
-        if (model.isPressed() 
-            && (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)
+
+        if (model.isPressed())
           model.setArmed(true);
-        else
-          model.setArmed(false);
       }
   }
 
   /**
    * Accept a mouse exit event and set the button's model's "rollover"
    * property to <code>false</code>, if it's "rolloverEnabled" property is
    * <code>true</code>. Also disarm the button.
    *
    * @param e The mouse exit event to accept
    */

Reply via email to