-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouse.java
More file actions
32 lines (29 loc) · 783 Bytes
/
Copy pathMouse.java
File metadata and controls
32 lines (29 loc) · 783 Bytes
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
package Swing;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class Mouse {
public static void main(String[] args) {
new Mou();
}
}
class Mou extends JFrame{
JLabel l=new JLabel("Get Loc");
public Mou(){
setLayout(new FlowLayout());
setTitle("Addition");
setVisible(true);
setSize(400,400);
add(l);
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
int x=e.getX();
int y=e.getY();
l.setText("("+x+","+y+")");
}
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}