This fixes the handling of mouse events for the SwingFramePeer. The
previous implementation was mostly bogus and cause NPEs and whatnot.
This is now checked correctly and the mouse event gets translated when
there is a menu bar so that it gets dispatched with the correct
coordinates.

2006-01-19  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/swing/SwingFramePeer.java
        (handleMouseEvent): Fixed handling of mouse events.
        (handleMouseMotionEvent): Fixed handling of mouse events.


/Roman
Index: gnu/java/awt/peer/swing/SwingFramePeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/swing/SwingFramePeer.java,v
retrieving revision 1.1
diff -u -r1.1 SwingFramePeer.java
--- gnu/java/awt/peer/swing/SwingFramePeer.java	14 Jan 2006 00:26:26 -0000	1.1
+++ gnu/java/awt/peer/swing/SwingFramePeer.java	19 Jan 2006 20:17:29 -0000
@@ -155,11 +155,19 @@
   {
     Point p = ev.getPoint();
     Insets i = super.getInsets();
-    int menuHeight = menuBar.getHeight();
-    if (p.y >= i.top && p.y <= i.top + menuHeight)
-      menuBar.handleMouseEvent(ev);
-    else
-      super.handleMouseEvent(ev);
+    if (menuBar != null)
+      {
+        int menuHeight = menuBar.getHeight();
+        if (p.y >= i.top && p.y <= i.top + menuHeight)
+          menuBar.handleMouseEvent(ev);
+        else
+          {
+            ev.translatePoint(0, -menuHeight);
+            super.handleMouseMotionEvent(ev);
+          }
+      }
+
+    super.handleMouseEvent(ev);
   }
 
   /**
@@ -171,10 +179,18 @@
   {
     Point p = ev.getPoint();
     Insets i = super.getInsets();
-    int menuHeight = menuBar.getHeight();
-    if (p.y >= i.top && p.y <= i.top + menuHeight)
-      menuBar.handleMouseMotionEvent(ev);
-    else
-      super.handleMouseMotionEvent(ev);
+    if (menuBar != null)
+      {
+        int menuHeight = menuBar.getHeight();
+        if (p.y >= i.top && p.y <= i.top + menuHeight)
+          menuBar.handleMouseMotionEvent(ev);
+        else
+          {
+            ev.translatePoint(0, -menuHeight);
+            super.handleMouseMotionEvent(ev);
+          }
+      }
+
+    super.handleMouseMotionEvent(ev);
   }
 }
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to