I am currently building a program for a school project. The program involves mouselistening that i recently handeled from the main class of the program. However, the mouse activity became too much work for the animation thread to handle along with the animation stuff it does. So i decided to move the mouse listening to a seperate class called MouseClass. I implemented the usual, mouselitener, mousemotionlistener and so on, but i can't call the method addMouseListener and addMouseMotionListener. I looked around in the API docs for this method and i found that it belonged to the Object class. I extended, imported, hell even made an Object object, but i strill can't add the mouse listeners. You guys are good programmers and im in need of assistance since i need to have a demo ready of this in 4 weeks. Could you guys help me out? =)

Here is the source for MouseClass, i appologize if it is a bit messy, it's heavily under construction.

I think you have to read up on how interfaces actually work. addMouseListener() is not something magic in which you always pass in this and which is always invoked from the this reference. The method addMouseListener() is defined in Component, so you need a reference to a Component and call addMouseListener() with an instance that has a class that implements the MouseListener interface.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

Im sorry, but I still can't seem to grasp how I am supposed to use this. Im building the program in applet form so when i place addMouseListener(this) in the class that serves as the main class it works, but not when i place those methods in a class that doesn't extend Applet. I managed to make it compile now though, but it doesn't registers any mousemotion or mouseclicks.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org