Listening to applet moved around

S

simplicity

Is there a way to detect the changes in screen location of the applet
as its parent browser is moved or resized?

I have the applet which start java.awt.Frame and places is directly on
top of the applet. I would like to be able to make this Frame follow
the applet location when the browser window is moved or resized. I got
the following working quite fine:

class OverlayWindow extends Frame implements MouseListener,
MouseMotionListener {
...
}

public class MyApplet extends Applet implements Runnable,
MouseListener, MouseMotionListener {
OverlayWindow overlay; // overlaying frame
...

public void mouseMoved(MouseEvent e) {
...
overlay.setLocation(this.getLocationOnScreen().x,
this.getLocationOnScreen().y);
}
}

The problem is that the mouseMoved() kicks in only after the browser
window is moved and the cursor comes back into the area occupied by
the applet.

I would prefer to get the overlay frame follow the applet as it
changes the locations. I looked at WindowListener interface but do not
see anything related to changing the window location.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top