Reputation: 68
I am trying to create a mouse listener class, simply for detecting mouse clicks. My code
package game.input;
import java.awt.event.*;
import java.awt.*;
public class Mouse implements MouseAdapter{
public Mouse(Component c){
c.addMouseListener(this);
}
public boolean mouseClicked(MouseEvent e) {
return true;
}
}
is giving me two errors:
How can I solve this two problems and accomplish the simple task of creating a detector for mouse clicks? This is the first time I write a MouseListener, so any other comments about mistakes I have done are welcome.
Upvotes: 0
Views: 233
Reputation: 347204
MouseAdapter
is a class
not a interface
, you need to use extends
instead of implements
public class Mouse extends MouseAdapter{
Take a look at
For more details
FYI...
public boolean mouseClicked(MouseEvent e) {
Will never be called, as it does not meet the requirements of the MouseListener
interface contract, it should be...
@Override
public void mouseClicked(MouseEvent e) {
Upvotes: 4