We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Catch mouseEntered or mouseExited while Dragging

baresse asked
Medium Priority
Last Modified: 2008-03-10

I've written an applet in which I want to catch the mouseEntered and mouseExited event on a component while the user is dragging over it.

It's works fine with Netscape, but not with Internet Explorer...

In Internet Explorer the MouseExited() method raises when the user release the button !

It's a problem for me because, I use this method to automatically scroll my image in a scrollpane when the user exits the component while he's dragging.

I'm looking for code...

Watch Question

Hi 'baresse',

This example I made to test the feature (or bug :-) you described.
      A basic extension of the java.applet.Applet class

import java.awt.*;
import java.applet.*;

public class applet_tester extends Applet
      public void init()
            // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
            // This code is automatically generated by Visual Cafe when you add
            // components to the visual environment. It instantiates and initializes
            // the components. To modify the code, only use code syntax that matches
            // what Visual Cafe can generate, or Visual Cafe may be unable to back
            // parse your Java file into its visual environment.
            tester_button = new java.awt.Button();
            tester_button.setBackground(new Color(12632256));
            status = new java.awt.Label("outside",Label.CENTER);
            SymMouse aSymMouse = new SymMouse();
      java.awt.Button tester_button;
      java.awt.Label status;

      class SymMouse extends java.awt.event.MouseAdapter
            public void mouseExited(java.awt.event.MouseEvent event)
                  Object object = event.getSource();
                  if (object == tester_button)

            public void mouseEntered(java.awt.event.MouseEvent event)
                  Object object = event.getSource();
                  if (object == tester_button)

      void testerButton_MouseEntered(java.awt.event.MouseEvent event)
            // to do: code goes here.
            // Set the text for Label...

      void testerButton_MouseExited(java.awt.event.MouseEvent event)
            // to do: code goes here.
            // Set the text for Label...

It worked fine on the Netscape 4.5
It worked fine on IE 4.0

Can you please test it on your machine and tell me?



Yes this feature is fine for me too...

But, it's while the user is "Dragging" with the mouse there is a problem...

My component has a MouseMotionListener too, and implements some
feature is the "mouseDragged()" method.

The problem is that the "mouseEntered()" and the "mouseExited()" methods aren't executed while the user is "dragging" (i.e. mouseDragged() method is executing). They are just fire after the user releases the mouse button and so stop dragging.


I see your point. I modified the example and it really does not work under IE 4.0.

I can suggest a nasty work around. When you detect IE in you applet, start a separate thread that checks for the mouse position over the component and does what it needs.

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


It was nearly my solution...

Thanks for having look at my problem !

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.