summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2006-03-22 20:39:44 +0000
committerMark Wielaard <mark@klomp.org>2006-03-22 20:39:44 +0000
commitd0ff75c28cb7f8bce70d0dcfa4c3cde12a9aa14d (patch)
treeb88dfc26dfb8538cc8e054c6498425ac8abe79d9
parentacb04b359731ebe0251007a9502ffa7abd21fccb (diff)
downloadclasspath-d0ff75c28cb7f8bce70d0dcfa4c3cde12a9aa14d.tar.gz
Fixes bug #26301
* gnu/java/awt/peer/GLightweightPeer.java: Extend MouseAdapter. (GLightweightPeer(Component)): Install MouseListener. (setCursor): Implement. (mouseEntered): New method.
-rw-r--r--ChangeLog8
-rw-r--r--gnu/java/awt/peer/GLightweightPeer.java34
2 files changed, 39 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a1446829f..b7bcb99af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-22 Mark Wielaard <mark@klomp.org>
+
+ Fixes bug #26301
+ * gnu/java/awt/peer/GLightweightPeer.java: Extend MouseAdapter.
+ (GLightweightPeer(Component)): Install MouseListener.
+ (setCursor): Implement.
+ (mouseEntered): New method.
+
2006-03-22 Tom Tromey <tromey@redhat.com>
* javax/swing/plaf/synth/ColorType.java (MAX_COUNT): No longer
diff --git a/gnu/java/awt/peer/GLightweightPeer.java b/gnu/java/awt/peer/GLightweightPeer.java
index daaa143d0..4076ba531 100644
--- a/gnu/java/awt/peer/GLightweightPeer.java
+++ b/gnu/java/awt/peer/GLightweightPeer.java
@@ -1,5 +1,5 @@
/* GLightweightPeer.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,11 +54,14 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
+import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
@@ -79,7 +82,7 @@ import java.awt.peer.LightweightPeer;
* Lightweight components are painted directly onto their parent
* containers through an Image object provided by the toolkit.
*/
-public class GLightweightPeer
+public class GLightweightPeer extends MouseAdapter
implements LightweightPeer, ContainerPeer
{
private Component comp;
@@ -89,6 +92,7 @@ public class GLightweightPeer
public GLightweightPeer(Component comp)
{
this.comp = comp;
+ comp.addMouseListener(this);
}
// -------- java.awt.peer.ContainerPeer implementation:
@@ -247,7 +251,25 @@ public class GLightweightPeer
public void setBounds(int x, int y, int width, int height) {}
- public void setCursor(Cursor cursor) {}
+ /**
+ * Sets the cursor on the heavy-weight parent peer.
+ * Called by the MouseListener on mouse enter.
+ */
+ public void setCursor(Cursor cursor)
+ {
+ Component p = comp.getParent();
+ while (p != null && p.isLightweight())
+ p = p.getParent();
+
+ if (p != null)
+ {
+ // Don't actually change the cursor of the component
+ // otherwise other childs inherit this cursor.
+ ComponentPeer peer = p.getPeer();
+ if (peer != null)
+ peer.setCursor(cursor);
+ }
+ }
public void setEnabled(boolean enabled) {}
@@ -341,4 +363,10 @@ public class GLightweightPeer
{
}
+
+ /** MouseListener for cursor changes. */
+ public void mouseEntered(MouseEvent event)
+ {
+ setCursor(comp.getCursor());
+ }
}