Capture Mouse Position outside an applet

Dear All,
I'm working on an applet that needs to know the actual position of the mouse cursor outside its area
(i.e.: else where on the screen), is that possible?
Thank you in advance.

As far as I know, no. Applets know about the mouse only when it's inside the applet area.

Similar Messages

  • Get mouse position outside application

    Hi,
    I need to know the position outside my java application, but I don't know on what I should add the MouseMotionListener. Any suggestions anyone?
    I'm running Microsoft Windows..
    Thanx,
    Jesse

    can't do that without JNI and a mouse hook.

  • How to capture mouse envents outside VI window?

    Hello,
           I want to capture mouse envents occured outside the VI window. I searched in NI web and only found that has example capture the mouse envents inside the VI window. If anyone can help me please email to [email protected] or [email protected]
    Thanks and Best Regards

    By the way, I'm using LabVIEW 6.1 PDS..

  • Mouse position outside of the top-most container

    I know how to acquire the position of the mouse through either the MouseListener or MouseMotionListener interfaces by calling the getX() and getY() of the MouseEvent class.
    But if the mouse is moved outside of the top-most container, eg. a JFrame, then the methods in the two listener interfaces above aren't called.
    So, does anyone know how I can retrieve the position of the mouse if it is outside the JFrame?
    Thanks,
    Dewi Williams

    As far as I know this is not possible using pure Java. Search the native methods forum for the OS(s) you are supporting and this topic.

  • Capture Mouse Focus for Applet

    Hey,
    I am writing an applet, and would like to capture the mouse focus entirely within my applet. Let me explain what I mean:
    - You click the applet, your mouse pointer vanishes.
    - Now no matter how far to the right you move your mouse, it will not pop out of the applet. It is "locked" inside.
    - You are still receiving mouse events from within this applet. You have essentially changed the area of effect to be the bounds of the applet.
    An example of this functioning would be any video game that runs in windowed mode. Focus the game, and you'll see that your mouse never exceeds the bounds of the applet. In windows you alt-tab and now you regain your mouse pointer.
    Is this possible? Anyone know how to do it?
    Thanks.
    Jesse

    You can get the focus by:
    <script type="text/javascript">
         onload = function()
              document.getElementsByTagName( "applet" )[0].focus();
    </script>
    In the applet mousemove event:
    - Set the mouse cursor to null (invisible in the applet)
    - Draw a small graphic at mouse position instead, doing the bounds checking.
    - This gives you a game cursor in the applet which behaves as you wish.
    - The "real" cursor is only visible outside the applet.
    BTW,
    KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner())
    returns null if the applet does not have focus (handy for pausing your app)
    AFAIK, applets themselves cannot grab focus (out of the sandbox)

  • Mouse position capturing

    I was wondering if there is a way to capture the mouse position w/o the use of a frame or jframe? I already know how to use the MouseListener on the JFrame/Frame, but that is no help to me since I'm not using a frame at all. Any suggestions????

    What is your goal. This will work -- (the window is 1 pixel!) -- because the robot starts a "drag" and
    swing has mouse capture during drag, but as soon as the use clicks, it's over...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) throws AWTException {
            JWindow w = new JWindow();
            Container cp = w.getContentPane();
            cp.addMouseMotionListener(new MouseMotionListener() {
                public void mouseDragged(MouseEvent e) {
                       System.out.println(e.getPoint());
                public void mouseMoved(MouseEvent e) {
            w.setBounds(new Rectangle(0,0,1,1));
            w.setVisible(true);
            Robot rob = new Robot();
            rob.mouseMove(0,0);
            rob.mousePress(InputEvent.BUTTON1_MASK);
            rob.mouseMove(100,100);
    [/code[

  • Mouse position help

    When using MouseListener and MouseMotionListener in an applet, I can not record events that happen outside the applet. Is there a way to record the x and y position of the mouse along with button presses when they occur outside the applet window? Thank you for your time.

    >
    I want to make a program to repeats a bunch of steps on my computer. However, while making it, I found it too hard to hardcode in the co-ordinates. Therefore, I want to record my actions so that I can repeat them.
    My plan is to have it record where I click into a text file, then the robot program will read from the text file and move the mouse to those positions and perform the same action everyday at a specific time, like when I wake up or come home. >It would be safer and more reliable to open a File object pointing to the text file, then do the edits using standard Java classes (such as a RandomAccessFile).
    >
    It doesn't need to be an applet, it can be an application too.>That is good, since the applet would need to be digitally signed in order to access the file system or the Robot.
    If this is a 'one off' app. for yourself, it is best launched as a plain application (JFrame without JWS).
    So to sum up. I do not think the Robot and related classes can provide the functionality you require, which is far easier/more reliable to program as I stated above.

  • Mouse position inside a movieclip area

    hey
    i am trying to solve this problem:
    how can i test the position of the mouse inside the area of a specific movieclip WITHOUT using rollover and rollout events?
    the movieclip is the irregular shape (star)
    i need to do some action according to the position of mouse (inside/outside of the movieclip area) but i can not use rollover event because i have a button placed over the movieclip.
    thanks for help

    it'll probably be easier for you to change your setup so you can use a rollover/rollout.  otherwise, you have to use a shape-based hittest (check gskinner) or the geometry of your shape.

  • Mouse Position at dragDrop event

    I'm dragging and dropping items between canvas containers. When I drop an item, the dragDrop event fires. However, I can't seem to find the mouseX and mouseY values of the drop target container, at the point when the item is dropped. Once the mouseDown event fires to start the drag, it seems as though Flex stops capturing the mouseX and mouseY values.
    I put a mouseMove event listener on the container where I'm dropping, and as soon as the mouseDown event starts, the mouseMove event stops.
    I looked at mouseUp, and while that gives me the correct current mouse position, it is triggered after the dragDrop event, making it too late to use the x and y position of the item I dropped.
    How do I find where the point where I dropped the item?

    As soon as the mouseDown event is triggered, the mouseMove event no longer triggers. Thank you for the link. I've read that many times while working on this. What it doesn't address is the position of the item dropped. The only way I can think of to get around this is to listen for the mouseUp instead of the drapDrog event, but that should not be necessary. Use the code below, as an example. No matter where you drop the panel in the second canvas, it puts it at the y value of the mouse at the moment the doDrag (or mouseDown) event triggered.
    <?xml version="1.0"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
        <mx:Script>
            <![CDATA[
                import mx.managers.DragManager;
                import mx.core.DragSource;
                import mx.events.DragEvent;
                import flash.events.MouseEvent;
                import mx.controls.Alert;
                private function mouseOverHandler(event:MouseEvent):void {
                    var dragInitiator:Panel=Panel(event.currentTarget);
                    var ds:DragSource = new DragSource();
                    ds.addData(dragInitiator, "format");
                    var PanelProxy:Panel = new Panel();
                    PanelProxy.height=myPanel.height;
                    PanelProxy.width=myPanel.width;               
                    DragManager.doDrag(dragInitiator, ds, event, PanelProxy, 0, 0, 1.00);
                private function dragEnterHandler(event:DragEvent):void {
                  if (event.dragSource.hasFormat("format"))
                    DragManager.acceptDragDrop(Canvas(event.currentTarget));
                private function dragOverHandler(event:DragEvent):void
                    if (event.dragSource.hasFormat("format")) {
                        if (event.ctrlKey) {                   
                            DragManager.showFeedback(DragManager.COPY);
                            return;
                        else {
                            DragManager.showFeedback(DragManager.MOVE);
                            return;
                    DragManager.showFeedback(DragManager.NONE);
                private function dragDropHandler(event:DragEvent):void {
                  if (event.dragSource.hasFormat("format")) {
                      var draggedPanel:Panel = event.dragSource.dataForFormat('format') as Panel;
                      var dropCanvas:Canvas = event.currentTarget as Canvas;
                      var newPanel:Panel = new Panel();
                      newPanel.x = 0;
                      newPanel.y = drpTgt.mouseY;
                      newPanel.height = draggedPanel.height;
                      newPanel.width = draggedPanel.height;
                      dropCanvas.addChild(newPanel);
                      Alert.show("Item Dropped at "+newPanel.y);
                private function dragCompleteHandler(event:DragEvent):void {
                    var draggedPanel:Panel =
                        event.dragInitiator as Panel;
                    var dragInitCanvas:Canvas =
                        event.dragInitiator.parent as Canvas;
                    if (event.action == DragManager.MOVE)
                        dragInitCanvas.removeChild(draggedPanel);
            ]]>
        </mx:Script>
        <mx:Canvas
            width="250" height="500" 
            borderStyle="solid"
            backgroundColor="#DDDDDD">
            <mx:Panel id="myPanel" x="10" y="192" width="150" height="150" layout="absolute" title="Test Panel" mouseMove="mouseOverHandler(event);" dragComplete="dragCompleteHandler(event);"/>
        </mx:Canvas>
        <mx:Canvas id="drpTgt"
            width="250" height="500" 
            borderStyle="solid"
            backgroundColor="#DDDDDD"
            dragEnter="dragEnterHandler(event);"
            dragOver="dragOverHandler(event);"
            dragDrop="dragDropHandler(event);" horizontalScrollPolicy="on">       
        </mx:Canvas>
    </mx:WindowedApplication>

  • Bitmap Rotation According to Mouse Position?

    Hi,
    I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
    for example: 

    Hi,
    I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
    for example: 
    Hello,
    To rotate that image, we need to deal with the following tips.
    1. The image size.
    If the area for that image rotated is not big enough, it will just lose some parts of that image.
    Here is a nice code shared in this thread
    http://stackoverflow.com/questions/5199205/how-do-i-rotate-image-then-move-to-the-top-left-0-0-without-cutting-off-the-imag/5200280#5200280.
    private Bitmap RotateImage(Bitmap b, float Angle)
    // The original bitmap needs to be drawn onto a new bitmap which will probably be bigger
    // because the corners of the original will move outside the original rectangle.
    // An easy way (OK slightly 'brute force') is to calculate the new bounding box is to calculate the positions of the
    // corners after rotation and get the difference between the maximum and minimum x and y coordinates.
    float wOver2 = b.Width / 2.0f;
    float hOver2 = b.Height / 2.0f;
    float radians = -(float)(Angle / 180.0 * Math.PI);
    // Get the coordinates of the corners, taking the origin to be the centre of the bitmap.
    PointF[] corners = new PointF[]{
    new PointF(-wOver2, -hOver2),
    new PointF(+wOver2, -hOver2),
    new PointF(+wOver2, +hOver2),
    new PointF(-wOver2, +hOver2)
    for (int i = 0; i < 4; i++)
    PointF p = corners[i];
    PointF newP = new PointF((float)(p.X * Math.Cos(radians) - p.Y * Math.Sin(radians)), (float)(p.X * Math.Sin(radians) + p.Y * Math.Cos(radians)));
    corners[i] = newP;
    // Find the min and max x and y coordinates.
    float minX = corners[0].X;
    float maxX = minX;
    float minY = corners[0].Y;
    float maxY = minY;
    for (int i = 1; i < 4; i++)
    PointF p = corners[i];
    minX = Math.Min(minX, p.X);
    maxX = Math.Max(maxX, p.X);
    minY = Math.Min(minY, p.Y);
    maxY = Math.Max(maxY, p.Y);
    // Get the size of the new bitmap.
    SizeF newSize = new SizeF(maxX - minX, maxY - minY);
    // ...and create it.
    Bitmap returnBitmap = new Bitmap((int)Math.Ceiling(newSize.Width), (int)Math.Ceiling(newSize.Height));
    // Now draw the old bitmap on it.
    using (Graphics g = Graphics.FromImage(returnBitmap))
    g.TranslateTransform(newSize.Width / 2.0f, newSize.Height / 2.0f);
    g.RotateTransform(Angle);
    g.TranslateTransform(-b.Width / 2.0f, -b.Height / 2.0f);
    g.DrawImage(b, 0, 0);
    return returnBitmap;
    2. The location of that control which displays that image.
    If we use a picturebox, and set its sizemode to autosize like the following line, then if you just want to rotate that image to show, and you don't want to that affects the original image, then we need to keep its center point.
    this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
    We could add resize event handler after we set image for that picturebox.
            Point pOrign;
            Size sOrign;private void Form1_Load(object sender, EventArgs e)
    this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
    Image img = Image.FromFile(@"D:\Documents\New folder\New folder\TestImage.PNG");
    this.pictureBox1.Image = img;
    this.pictureBox1.InitialImage = img;
    pOrign = new Point(this.pictureBox1.Left , this.pictureBox1.Top );
    sOrign = new Size(this.pictureBox1.Width, this.pictureBox1.Height);
    this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
    this.pictureBox1.Resize += pictureBox1_Resize;
    private void pictureBox1_Resize(object sender, EventArgs e)
    this.pictureBox1.Left = this.pOrign.X + (this.sOrign.Width - this.pictureBox1.Width) / 2;
    this.pictureBox1.Top = this.pOrign.Y + (this.sOrign.Height - this.pictureBox1.Height) / 2;
    3. The angle between that center point and your mouse postion.
    We could get that value inside the picturebox's container's mouse_move event.
    Double angleNew ; private void pictureBoxContainer_MouseMove(object sender, MouseEventArgs e)
    angleNew = Math.Atan2(this.pOrign.Y + this.sOrign.Height / 2 - e.Y, this.pOrign.X + this.sOrign.Width/2 - e.X) * 180.0 / Math.PI;
    But when to start rotate that image, it should be your chooice, and you could decide when rotate that image with the following line.
    this.pictureBox1.Image = (Image)RotateImage(new Bitmap(this.pictureBox1.InitialImage), (float)angleNew);
    If you just want to save that change to that image, then you could save that bitmap to file directly.
    Happy new year.
    Regards.
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How do you Capture Mouse?

    I'm new at Flex and trying to make a graphics editor for which I need the user to be able to resize the graphs the same way most graphics editors do - with a resize box. So what I'm making now is a class (that extends UIComponent) that have 4 little squares (that extend UIComponent too) at the corners that the user should use as handles to resize something. So I all need to do right now is to make them react properly to mouse inputs: the one at the top right should have the same "x" position as the one at the bottom right if the user is moving the bottom right one and so on. What I do is call startDrag in the MOUSE_DOWN event for each square and then in the MOUSE_MOVE event I move the others squares accordingly. The problem is that the square being dragged moves faster than all the others. If I could just capture mouse and then do all the dragging stuff myself that would make it a lot easier. But it seems that they didn't implement that function so, does anyone know any other possible way to do what I'm trying to do?

    Solved my problem. Here's the code in case is useful for anyone:
    // Make an event listener like this for every mouse event
    public function OnMouseDown(event:MouseEvent):void
         if(event.target is DisplayObject){
              if(!MouseOwner.contains(DisplayObject(event.target))) event.stopPropagation();
         else event.stopPropagation();
    public function CaptureMouse(Element:DisplayObjectContainer):void
        this.addEventListener(MouseEvent.MOUSE_DOWN, OnMouseDown, true);
        // Keep adding listeners for every mouse event
        MouseOwner = Element;

  • Capture mouse in a component

    May I capture the mouse in a window?
    In a simple application, I want to capture the mouse in the window. That is, when I move the mouse, there are no MouseEvent.MOUSE_MOVED, but MouseEvent.MOUSE_DRAGGED. So I can get the position of the mouse even the mouse position is out of the window. Just like when we press the leftbutton and move it (in this case, you may find you can get the events of the mouse even in the window even the mouse 's position is out of the window )
    In Windows system, the function is SetCapture and ReleaseCapture
    But in Javva, how can I do it?

    I don't think there is a way to set capture. You just have to look for MouseEvent. MOUSE_DRAGGED which will be sent when you start dragging.

  • Manually shift mouse position

    During a drag/drop operation, I want to do some calculation
    if the user pauses for a 1/2 second and potentially reposition the
    drag proxy object relative to the mouse or perhaps just move the
    mouse location. Essentially a “snap to grid” type
    thing. I've captured the pausing with a timer event but I need to
    do the repositioning. Does anyone know if there is there a way to
    do one of the following?
    1) Shift the offset of the proxy image on the fly?
    2) Shift the actual mouse position on the fly which will also
    shift the proxy image?
    I'd prefer the 1st option but the 2nd would work too.
    Thanks very much in advance!

    I'm sure there's somebody out there who would know better
    than I do, but in lieu of that, my guesses for you:
    1) No - I don't think so, though you could implement the
    drag/drop functionality yourself and have full control.
    2) I really doubt it, since the position of the mouse is
    courtesy of the operating system.

  • Zooming image from mouse position(like in  windows vista photo gallery)

    hello all;
    here's my situation, hope someone can help..
    i wanna Zoom an image, which zoom from my mouse position
    like in windows photo gallery in windows vista
    so i do this..
    g2.translate(iMoux,iMouy);       
            g2.scale(zoom, zoom);       
            g2.translate(-iMoux,-iMouy);       
            g.drawImage(icon.getImage(), iSposx, iSposx, d.width/2-iValue, d.height-iBawah, null);
            g.drawImage(icon2.getImage(), d.width/2, iSposy, d.width/2-iValue, d.height-iBawah, null);the problem come when i move my mouse to the different location (like from top right to bottom left)
    the zoom image displayed in the screen like jump from latest location to new location
    anybody can help me...a clue how to do that?
    thx appreciate your help guys
    mao
    Edited by: KingMao on 31 Mei 08 14:27

    Hi Frank.
    Thanks for the response.
    Agreed, the pertinent question is why can't my colleague edit the JPG exported by Aperture. It's probably also worth pointing out, the same problem occurs with JPGs exported from iPhoto.
    The Windows software usually plays nicely with JPGs by all acounts, just not the ones I send - which I do via eMail or my public space on Mobile Me incidently.
    So, another key question is: all settings being equal (color profile, quality, etc.) are the JPGs as produced by iPhoto and Aperture indistinguishable from those produced by other apps on other platforms - i.e. does the use of JPG enforce a common standard?
    If that is the case, I suspect ours might be a permissions issue.
    According to the Microsoft support page on editing in Windows Live Photo Gallery, the inability to edit a picture is commonly caused by unsupported file type, or read-only attribute set on the file.
    Unfortunately, he and I are not in the same place, and he's not particularly au-fait with this type of problem solving. Hence, before involving him, I'd like to know:
    1. it's possible (i.e. someone else does it), and,
    2. what's involved (at my end and/or his).
    Thanks again,
    PB

  • System not sensing mouse position

    Starting today, my computer (iMac G5 PPC) no longer senses the position of my mouse pointer. For instance:
    - The dock doesn't magnify when the mouse is in it
    - None of the corners activate things like screensaver, expose, desktop
    - When I select a menu in the menu bar, moving the mouse over another menu item doesn't open that menu.
    In other words, OSX simply has no clue where my mouse pointer is located as I move it for all those neat automatic things. Yet, I can still use the mouse to click on items to make them work, then OSX knows where the mouse is.
    I've rebooted several times to no effect, but did notice something. As apps start up, the instant a window opens, OSX will sense the mouse position for that brief moment. For example, putting the mouse over the dock doesn't magnify, but when an app window appears, the dock will magnify that very instance. Moving the mouse out of the dock area doesn't unmagnify the dock, it's stuck in that state until either another window opens, causing OSX to sense the new position, or I click any mouse button which all gets OSX's attention and senses the mouse position.
    The pointer never changes when I'm over things like Links.
    Strange stuff. The mouse moves fine, it's just not being detected as it moves.
    Now, yesterday I installed a new ScanSnap scanner with the ScanSnap Manager software and Acrobat Standard ver. 7. But the mouse didn't have this behavior yesterday, or even this morning. This strange problem just appeared out of the blue mid-day today.
    I've since used Disk Utility and Onyx, and re-installed the 10.4.9 update. I switched to another user account, no difference, so it's definitely system wide.
    This doesn't stop me from using my iMac, but I just don't know how to fix this mouse issue besides a OSX re-install.

    Ok everybody, I finally got proper behavior, it's just too bad I'm not sure of the procedure.
    When I go to bed I usually run the mouse pointer to the upper left corner to activate the screensaver. Of course it didn't work. But I also knew that clicking a button causes the mouse to be sensed, so I was pushing some of the buttons while in the corner to see if I could get the screensaver going.
    Well, after doing this, everything is back to normal operation again. So, I fixed it totally by accident. Makes me wonder if there's some features that are turned on and off somehow by doing whatever it was I did up in that corner.
    Just so you know, I use a Logitech Cordless Optical Trackman. I swapped to the original Apple corded mouse but that made no difference.
    I never had a chance to try the suggestions since I just read them before posting this.
    Anyway, I hope I don't do again whatever it was that caused the behavior, but I am going to store this info in DEVONthink just in case something like this happens again.
    Anyway, it would still be interesting if someone could shed some light on this fix I accidently found. Perhaps some hidden capabilities/features? Or just dumb luck?

Maybe you are looking for

  • HDMI On Mac Mini Late 2012: Problem with hardware?

    Just converted from PC to Mac. Purchased latest mac mini (Late 2012 version) Have tried several monitors through HDMI port and each time the picture quality is poor with very bad text resolution. Have tried HDMI to HDMI  and also tried HDMI to DVI ad

  • External HTML files

    Can anyone help me with a problem I'm having? I am currently trying to automate generation of the locale specific public API document for the product we make. Part of this documentation requires that some of the generic classes we use are also shown

  • Nfs client ls /data/rw10 nfs client on mount: Permission denied

    We are running an 800 cpu amd solaris 10 x64 cluster for HPC and an 512 cpu ultrasparc cluster solaris 10 for high throughput. Until now the nfs servers played ball and I did not experience real difficulties. I am running two Solaris 10 x64 servers s

  • Nikon D800 Camera Raw and CS 5

    I rently bought a Nikon D800 and my Photoshop CS 5 Extented (Education Edition) cannot view the files (not in PS nor in Bridge). Can you send me a link to a downloid that would make this possible? My Mac Operating system is OSX 10.5.8 and my Adobe Ph

  • Iphoto 09 does not recognize .jpg images?????

    Recently updated to 10.5.6 + iLife 09 +iWork 09 (box set). First time trying to add pictures to iPhoto 09 I get the following message... "Unreadable Files: 20 The following file could not be imported. (The file is in an unrecognized format)" These fi