forked from mohammedabdulbari/Java-SE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonDemo.java
More file actions
46 lines (33 loc) · 754 Bytes
/
ButtonDemo.java
File metadata and controls
46 lines (33 loc) · 754 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package buttondemo;
import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame implements ActionListener
{
int count=0;
Label l;
Button b;
public MyFrame()
{
super("Button Demo");
l=new Label(" "+count);
b=new Button("Click");
b.addActionListener(this);
setLayout(new FlowLayout());
add(l);
add(b);
}
public void actionPerformed(ActionEvent e)
{
count++;
l.setText(" "+count);
}
}
public class ButtonDemo
{
public static void main(String[] args)
{
MyFrame f=new MyFrame();
f.setSize(400,400);
f.setVisible(true);
}
}