-
Notifications
You must be signed in to change notification settings - Fork 243
/
mouse.java
36 lines (35 loc) · 832 Bytes
/
mouse.java
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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class mouse extends Frame implements MouseListener{
static JLabel l;
mouse()
{
}
public void mouseClicked(MouseEvent e) {
l.setText("Mouse Clicked");
}
public void mouseEntered(MouseEvent e) {
l.setText("Mouse Entered");
}
public void mouseExited(MouseEvent e) {
l.setText("Mouse Exited");
}
public void mousePressed(MouseEvent e) {
l.setText("Mouse Pressed");
}
public void mouseReleased(MouseEvent e) {
l.setText("Mouse Released");
}
public static void main(String[] args) {
JFrame f = new JFrame("Mouse");
f.setSize(300,300);
mouse m = new mouse();
f.addMouseListener(m);
JPanel p = new JPanel();
l = new JLabel();
p.add(l);
f.add(p);
f.setVisible(true);
}
}