-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonEvent.java
57 lines (43 loc) · 1.1 KB
/
ButtonEvent.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.bridgelabz.functional;
import java.awt.Button;
import java.awt.Frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class ButtonEvent {
Button b1;
int count=0;
public void MultipleClicks()
{
Frame f=new Frame();
b1 = new Button("CLICK");
b1.setFocusable(true);
b1.addMouseListener(new MouseListener());
f.add(b1);
f.setSize(550, 550);
f.setVisible(true);
}
class MouseListener extends MouseAdapter
{
int i;
public long firstClick = 0;long Time;
public void mouseClicked (MouseEvent e)
{
Time = System.currentTimeMillis();
long interval = Time - firstClick;
if (interval < 500)
{
System.out.println("Hello Sushant.........." );
firstClick = 0;
}
else
{
firstClick = Time;
}
}
}
public static void main(String args[])
{
ButtonEvent e=new ButtonEvent();
e.MultipleClicks();
}
}