package com.evenhandling;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
public class MouseDemo extends Frame implements MouseListener,MouseMotionListener{
MouseDemo() {
setSize(500,500);
setVisible(true);
addMouseListener(this);
addMouseMotionListener(this);
}
public void mouseClicked(MouseEvent d) {
setBackground(Color.GREEN);
}
public void mouseEntered(MouseEvent arg0) {
setBackground(Color.white);
}
public void mouseExited(MouseEvent arg0) {
setBackground(Color.black);
}
public void mousePressed(MouseEvent arg0) {
setBackground(Color.gray);
}
public void mouseReleased(MouseEvent arg0) {
setBackground(Color.blue);
}
public void mouseDragged(MouseEvent arg0) {
setBackground(Color.MAGENTA);
}
public void mouseMoved(MouseEvent arg0) {
setBackground(Color.red);
}
public static void main(String[] args) {
MouseDemo d=new MouseDemo();
}
}
Top
No comments:
Post a Comment