Use behaviour class to capture mouse motion

Hi,
I am trying to write a behavior class for mouse by extending the behavior class. But it does not seem to capture the mouse movement when I move the mouse. Here is my code. Plz help me to find out the problem.
import java.awt.event.*;
import java.util.Enumeration;
import javax.media.j3d.MouseBehavior;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.Transform3D;
import javax.media.j3d.WakeupOnAWTEvent;
import javax.media.j3d.WakeupCriterion;
import javax.media.j3d.WakeupCondition;
import javax.media.j3d.WakeupOr;
import java.awt.AWTEvent;
public class UserEyeBehavior extends MouseBehavior {
private TransformGroup sutg;
private ViewerCoordinates vc;
private float x=0;
private float y=0;
private float z=0;
/** Creates a new instance of UserEyeBehavior */
public UserEyeBehavior(TransformGroup sutg,ViewerCoordinates vc) {
this.sutg = sutg;
this.vc = vc;
private void setEvent()
WakeupCriterion[] criteria = new WakeupCriterion[2];
criteria[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
criteria[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED);
WakeupCondition condition = new WakeupOr(criteria);
this.wakeupOn(condition);
public void initialize()
System.out.println("in");
setEvent();
public void processStimulus(Enumeration criteria){
WakeupCondition condition;
AWTEvent[] events;
System.out.println("ahgghgfasdhg");
while(criteria.hasMoreElements())
System.out.println(2);
condition = (WakeupCondition)criteria.nextElement();
events = ((WakeupOnAWTEvent)condition).getAWTEvent();
for(int i=0;i<events.length;i++)
System.out.println(3);
if(events.getID() == MouseEvent.MOUSE_DRAGGED)
System.out.println(((MouseEvent)events[i]).getX()+" "+((MouseEvent)events[i]).getY());
else
System.out.println(((MouseEvent)events[i]).getX()+" "+((MouseEvent)events[i]).getY());
setEvent();
Main program section
//Add navigation in universe
UserEyeBehavior ueb = new UserEyeBehavior(su.getViewingPlatform().getViewPlatformTransform(),vc);
bg.addChild(ueb);

replace setEvent() call
by
wakeupOn(mouseCriterion);
Franck

Similar Messages

  • Using ref. class to capture DL path

    I have written code to download a file. How can I get the
    location of the file that the user has just saved it to on their
    local machine? Do you grab it when using the select listener for
    the file ref. class? I am going to post it to a textfield like
    such:

    Hi...
    Thanks for your repaly .
    and i am not bale to post a question in developer forum i tried hard but i didnt get .Can you plz explain me how to post a question in developer forum this is very helpfull for me.Because i never did this thing.

  • Plz Help! How to control mouse motion(use program to move/click the mouse)?

    Hi people, plz give me some help on this: I wanna control mouse motion at another program's window, eg. control mouse movement in Internet Explorer's window. For a particular pixel on the screen, I need to move the mouse onto it instantly, then click. Please note that the java program(no applet) is going to run at the background, the current active window is some other programs like IE, notepad, etc.
    Plz give me some clue about how to achieve this, thanks.
    Do I need to do this through windows API or it can be done purely in JAVA?
    Also, how to calculate the RGB color from a particular pixel on the screen?
    Thank you very much for your time, plz help :).

    The same question each day (exe) !!!
    There are many posts on this point!
    All the soft that allows the build a native executable file on Windows
    are not free!
    You can take a look at JET excelsior
    http://www.excelsior-usa.com/home.html
    Denis

  • 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;

  • Creating a triangle using polygon class problem, URGENT??

    Hi i am creating a triangle using polygon class which will eventually be used in a game where by a user clicks on the screen and triangles appear.
    class MainWindow extends Frame
         private Polygon[] m_polyTriangleArr;
                       MainWindow()
                              m_nTrianglesToDraw = 0;
             m_nTrianglesDrawn = 0;
                             m_polyTriangleArr = new Polygon[15];
                             addMouseListener(new MouseCatcher() );
            setVisible(true);
                         class MouseCatcher extends MouseAdapter
                             public void mousePressed(MouseEvent evt)
                  Point ptMouse = new Point();
                  ptMouse = evt.getPoint();
                if(m_nTrianglesDrawn < m_nTrianglesToDraw)
                                int npoints = 3;
                        m_polyTriangleArr[m_nTrianglesDrawn]
                      = new Polygon( ptMouse[].x, ptMouse[].y, npoints);
    }When i compile my code i get the following error message:
    Class Expected
    ')' expectedThe two error messages are refering to the section new Polygon(....)
    line. Please help

    Cannot find symbol constructor Polygon(int, int, int)
    Can some one tell me where this needs to go and what i should generally
    look like pleaseI don't think it is a good idea to try and add the constructor that the compiler
    can't find. Instead you should use the constructor that already exists
    in the Polygon class: ie the one that looks like Polygon(int[], int[], int).
    But this requires you to pass two int arrays and not two ints as you
    are doing at the moment. As you have seen, evt.getPoint() only supplies
    you with a single pair of ints: the x- and y-coordinates of where the mouse
    button was pressed.
    And this is the root of the problem. To draw a triangle you need three
    points. From these three points you can build up two arrays: one containing
    the x-coordinates and one containing the y-coordinates. It is these two
    arrays that will be used as the first two arguments to the Polygon constructor.
    So your task is to figure out how you can respond to mouse presses
    correctly, and only try and add a new triangle when you have all three of its
    vertices.
    [Edit] This assumes that you expect the user to specify all three vertices of the
    triangle. If this isn't the case, say what you do expect.

  • Apple TV, monitor use and lag time with mouse and keyboard

    I purchased an Apple TV so that I could use one monitor to switch between my Mac Mini and my MacbookPro. The monitor is hardwired to the Mini, but the MacbookPro uses airplay. My wireless mouse and keyboard lag with this setup. Is there a way to fix this?

    My contacts in Pyongyang and Interlaken tell me you have fallen in the abyss that "The Great Successor,” Kim Jong-un refers to when he goes to DisneyWorld. One is either ‘right’ or ‘wrong,’ never ‘helpful.’ However due to your Stalinist screen name, you’ve been awarded some slack.
    I didn’t see a reference to even a clue on the Apple TV site regarding my traumatic technological problem. I’ll be contacting the Grack Granny Smythe force at Apple’s underground facility at La Junta, CO.
    There will be a one way, non-stop, sleeper class Lockheed SR-71 waiting for you at Nantucket International if Tech Support for Apple TV denies that Apple TV exists any longer.

  • I need help adding a mouse motion listner to my game. PLEASE i need it for

    I need help adding a mouse motion listner to my game. PLEASE i need it for a grade.
    i have a basic game that shoots target how can use the motion listner so that paint objects (the aim) move with the mouse.
    i am able to shoot targets but it jus clicks to them ive been using this:
    public void mouse() {
    dotX = mouseX;
    dotY = mouseY;
    int d = Math.abs(dotX - (targetX + 60/2)) + Math.abs(dotY - (targetY + 60/2));
    if(d < 15) {
    score++;
    s1 = "" + score;
    else {
    score--;
    s1 = "" + score;
    and here's my cross hairs used for aiming
    //lines
    page.setStroke(new BasicStroke(1));
    page.setColor(Color.green);
    page.drawLine(dotX-10,dotY,dotX+10,dotY);
    page.drawLine(dotX,dotY-10,dotX,dotY+10);
    //cricle
    page.setColor(new Color(0,168,0,100));
    page.fillOval(dotX-10,dotY-10,20,20);
    please can some1 help me

    please can some1 help meNot when you triple post a question:
    http://forum.java.sun.com/thread.jspa?threadID=5244281
    http://forum.java.sun.com/thread.jspa?threadID=5244277

  • Using tie-classed to change name of file uploaded through FTP protocol srvr

    Hi,
    I'm trying to use the extendedPreAddItem (or Post) method in an S_TieFolder class to automatically change the name of a file (an S_PublicObject) when it enters a Folder (via an FTP put upload).
    I'm fiddling around with code like this:
    AttributeValue val = AttributeValue.newAttributeValue(newDocName);
    val.setName(Document.NAME_ATTRIBUTE);
    rightpo.setAttribute(val);
    But it does not work: in the FTP client the filename is indeed changed, but somewhere at lower levels the original filename is still being used...
    Any helpfull ideas would be appreciated.
    TOon

    I'm aware of this... My ftp-client (FTP-Voyager) will prompt me if I "put" a file that already exists in the remote folder, and ask me to go ahead and replace the file, or cancel the put-operation.
    However in this case the ftp-client sees file X' remotely and I'm putting file X, so it does not prompt me at all...
    Stopping and restarting the FTP-client (in case it caches remote folder-contents...) does not change the behaviour.
    Timewise this is what happens:
    1) I put file X.
    2) My S_TieFolder class (extendedPreAddItem) changes it's name into X'.
    3) The ftp-put successfully completes
    4) I refresh the remote folder contents and see the X' name instead of the original X name.
    5) I re-put X (and would now like to have it changed into file X'').
    6) Before my S_TieFolder code executes, something (I'm still suspecting the cm-sdk) deletes the X' file first... ==> the logfile does not show any communication with the ftp-client here now.
    7) Then my S_TieFolder code executes and changes the name into X''.
    8) I refresh the remote folder contents: File X' disappears, file X (just re-put) changes into X''.
    More testing has shown that I'm also not able to delete these files (whose names have been changed by S_TieFolder): 'file does not exist' error.
    I need to know:
    a) If changing the files name on-the-fly using S_Tie class is supported at all.
    and
    b) if so, what am I doing wrong?
    Thanks
    Toon

  • 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..

  • Is there any use for Class.getTypeParameters()?

    This is a quote from another Thread in this forum:
    How does erasure destroy reflection-related information? Methods getGenericInterfaces, getGenericSuperclass and getTypeParameters on java.lang.Class allow you to retrieve a lot of information on generic issues regarding a class. Obviously, that information is thus not destroyed.
    While I do agree that Generics do not destroy reflection, I wonder what they add to it.
    New types and methods are Class.getTypeParameters(), the interfaces java.lang.GenericDeclaration, java.lang.reflect.TypeParameter, java.lang.reflect.ParameterizedType etc...
    Could someone please give me an example of what I could do with all these new types and methods?
    It has been decided that Generics are implemented as a compile-time feature. At runtime, no information about the instantiated type parameters exists anymore. OK, so why clutter the core Java packages with a lot of seemingly useless new types and methods?

    Could someone please give me an example of what I
    could do with all these new types and methods?
    It has been decided that Generics are implemented as a
    compile-time feature. At runtime, no information about
    the instantiated type parameters exists anymore. OK,
    so why clutter the core Java packages with a lot of
    seemingly useless new types and methods?This is a very good question, and something I've been wondering about myself. I cannot determine how to get the runtime to give me an instance of WildcardType or ParamaterizedType, for example.
    Here's an extremely contrived example of how you can use Type bounds to effect runtime behaviour:
        class Processor<T> {       
        class StringProcessor<S extends String> extends Processor<S> {       
        public void whatKindOfProcessorIsItAnyway(Processor p) {
            Type processorType = p.getClass().getTypeParameters()[0].getBounds()[0];
            if ( String.class.equals(processorType) ) {
                System.out.println("I'm a string processor");
            } else {
                System.out.println("I process these: " + processorType);           
    whatKindOfProcessorIsItAnyway(new StringProcessor<String>());
            whatKindOfProcessorIsItAnyway(new Processor<Integer>());Outputs:
    I'm a string processor
    I process these: class java.lang.Object
    So you can see I can switch based on the type bounds compiled into the program, but I have no way of knowing that the second processor is actually instantiated with Integer, due to erasure.
    Infact, the only reason I would know anything about the actual type argument in the first instance is because String is final so '? extends String' -> String, for what its worth.
    Whether I can write a program that's actually useful using this information I've yet to determine, but I can imagine it could be useful for code generation.

  • How can I capture mouse click events on BSP or Web Dynpro ABAP Screen

    hi Guys,
    Currently we have a user inactivity problem,
    the requirement is: if user is clicking on BSP/Web Dynpro ABAP screen, he/she is considered active. so we need an mechanism to capture the mouse click event.
    Using Firebug, we found that this js is in the iframe which contains BSP/web dynpro scrren: /sap/public/bc/ur/nw5/js/languages/urMessageBundle_en.js
    we want to find this js file & put in some javascript code to track user's mouse click, but i cannot find it on server.
    while in ie if we type http://host:port/sap/public/bc/ur/nw5/js/languages/urMessageBundle_en.js
    this file can be downloaded, means this file is there.
    Any one can help on this issue? find the js file or another way to capture the mouse click event.
    Thanks a lot with points!

    Hi  Feng Guo,
                        We can not capture mouse click events on Web Dynpro ABAP Screen . I am not sure about BSP. But as for as I know the portal keep active the iViews until unless mouse clicks happens.
    But for your problem I think you can get solution by setting iView Expiration to some more time period.
    Regards,
    Siva

  • How to use the class CL_CTMENU with the method DISABLE_FUNCTIONS

    Hi Friends,
    How to de-activate some functions in the Menu bar?
    Eg: - Sales document
                 Create
                 Change
                 Display
    I want to de-activate "Change"
    In other words: - How to use the class CL_CTMENU with the method DISABLE_FUNCTIONS in my program.
    Regards,
    Hari
    Edited by: Bhatlapenumarthy Hari Krishna on Jun 9, 2008 5:22 PM

    Krishna,
    It is not possible to deactivate the CHANGE option in themenu bar using the method disable_functions of cass CL_CTMENU. This method allows you to deactivate only the function codes of the CONTEXT MENU, which is available only when u press the left mouse button.
    U can use the SET PF-STATUS 'XXX' EXCLUDING fcodes option to disable the CHANGE.
    *****Reward points if useful
    Regards,
    Kiran Bobbala

  • Reg: MouseListener and Mouse Motion Listener Interfaces

    Hi,
    Good day,
    I have added the mouselistener and mouse motion listeners to JButton..... With this i am trying to draw Circle and Line use mouse... When i was drawing at a particular point the actual drawn one is not placed at that point... so where can be error be present..how to overcome it.........
    Bye

    Insufficient information to find a solution. Please go through these links and respond accordingly.
    [How to ask questions the smart way|http://catb.org/~esr/faqs/smart-questions.html]
    SSCCE
    Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
    db

  • Detect Key Press and Mouse Motion in ONE event?

    Hi
    I am trying to create a functionality where a mouse motion from left to right performs one action, and the same motion while a given key is pressed performs another action.
    How can i combine the two events? How do I unify the KeyEvent and MouseEvent, particulary when I need to capture the directional motion of the mouse together with the key press?
    many thanks for any insight

    you cannot actualy combine them into 1 event but there is an easy way around this:boolean mouseKeyPressed = false;
    public void keyPressed (KeyEvent e)
      if (e.getKeyCode () == ??) \\ or e.isCtrlDown(), e.isAltDown(), ...
        mouseKeyPressed = true;
    public void keyReleased (KeyEvent e)
      if (e.getKeyCode () == ??) \\ or !e.isCtrlDown(), !e.isAltDown(), ...
        mouseKeyPressed = false;
    public void mouseMoved (MouseEvent e)
      if (mouseKeyPressed)
        //processAction
    }hope this helps,
    greetz,
    Stijn

  • Capturing Mouse Events On MediaPlayer

    Hi,
    I have created a video conference application based on JMF. In this application I am using MediaPlayer control to play the rtp stream. Now I want to capture Mouse Events like MouseClick and MouseMove. But sorry to say that I am not getting any event on MediaPlayer control. I have tried this on other controls and successful. Can anybody tells me how to capture mouse events on MediaPlayer.
    --ibrar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Mouse Events may only be capture INSIDE the java application frame. SO, if your desktop is not a java component, you will not be able to capture the events.
    However, you could maybe use JNI to use native methods so as to get the location of the mouse...
    vincent

Maybe you are looking for

  • How to Hit Request of Invoice NO In print Option Conditionaly

    Dear Friend i want display to my print option enable and disable according to condition.So i have done some code in my Sql Query.Print Option is display me enable and disable condiotanly correctly but where Print option is ebalbe to print ,When i pre

  • Calling one Web-Dynpro program into Another

    Hi All, I'm currently working on a Web-Dynpro program in which I am display 3 tabs(Using TabStrip) and in each tab I have a ViewContainer.   I want to be able to execute other Web-Dynpro programs within the Viewcontainers of the Tabs.  If the End-Use

  • ABAP Mapping - How to test it

    Hi, I'm trying to test the SAP example found  in document "How to use Abap-Mapping in XI 3.0". This one is: class interface = Z_TEST_ABAP_MAPPING method = IF_MAPPING~EXECUTE But I cannot test it. 1. In IR, when I uses the "Test" option inside my Inte

  • Exception while creating a Adaptive WebService model in CE 7.1

    Hi All, I am trying to call a Adaptive Web Service model in CE 7.1, I am getting the following exception. java.io.IOException: Cannot connect to http://ealpdcompiep:52000/wsnavigator/jsps/index.jsp?localWS=V1NfTURNX1JFVF9KVC9zYXAuY29tJTJGamFfbWF0ZXJp

  • My Iphone 4s goes into recovery mode after doing the IOS 6 update.

    I just tried doing the IOS6 update and after about 2hrs into it my phone goes into recovery mode. The Itunes icon appeared on the phone. When i connected it to Itunes, I tunes said i had to restore and update my phone. BTW my son did the update in ab