-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMouseHandling.java
More file actions
58 lines (58 loc) · 1.27 KB
/
Copy pathMouseHandling.java
File metadata and controls
58 lines (58 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.awt.event.*;
import java.awt.*;
public class MouseHandling extends Frame implements MouseListener, MouseMotionListener
{
MouseHandling()
{
addMouseListener(this);
addMouseMotionListener(this);
setSize(300,300);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent ce)
{
System.exit(0);
}
});
}
public void mouseDragged(MouseEvent e)
{
setBackground(Color.gray);
System.out.println("Mouse Dragged");
}
public void mouseMoved(MouseEvent e)
{
setBackground(Color.cyan);
System.out.println("Mouse Moved");
}
public void mouseClicked(MouseEvent e)
{
setBackground(Color.green);
System.out.println("Mouse Clicked");
}
public void mousePressed(MouseEvent e)
{
setBackground(Color.blue);
System.out.println("Mouse Pressed");
}
public void mouseReleased(MouseEvent e)
{
setBackground(Color.black);
System.out.println("Mouse Released");
}
public void mouseEntered(MouseEvent e)
{
setBackground(Color.red);
System.out.println("Mouse Entered");
}
public void mouseExited(MouseEvent e)
{
setBackground(Color.orange);
System.out.println("Mouse Exited");
}
public static void main(String[] args)
{
new MouseHandling();
}
}