-
Notifications
You must be signed in to change notification settings - Fork 0
/
ButtonExample.java
32 lines (31 loc) · 939 Bytes
/
ButtonExample.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
import java.awt.*;
import java.awt.event.*;
public class ButtonExample {
public static void main(String[] args) {
Frame f=new Frame("Button Example");
final TextField tf=new TextField();
tf.setBounds(50,50, 150,20);
Button b=new Button("MTech");
Button c=new Button("MCA");
b.setBounds(50,100,60,30);
c.setBounds(100,100,60,30);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
tf.setText("You selected MTech course.");
}
});
c.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
tf.setText("You selected MCA course.");
}
});
f.add(b);f.add(tf);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
f.add(c);f.add(tf);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
}