Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package samples;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import acm.graphics.GCanvas;
- public class MyCanvas extends GCanvas implements MouseListener, MouseMotionListener {
- // Constructor
- public MyCanvas() {
- addMouseListener(this);
- addMouseMotionListener(this);
- }
- @Override
- public void mouseClicked(MouseEvent arg0) {
- System.out.println("Clicked");
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- System.out.println("Entered");
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- System.out.println("Exited");
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- System.out.println("Pressed");
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- System.out.println("Released");
- }
- @Override
- public void mouseDragged(MouseEvent arg0) {
- System.out.println("Dragged");
- }
- @Override
- public void mouseMoved(MouseEvent arg0) {
- System.out.println("Moved");
- }
- }
Add Comment
Please, Sign In to add comment