-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSetColor.java
More file actions
41 lines (34 loc) · 884 Bytes
/
SetColor.java
File metadata and controls
41 lines (34 loc) · 884 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
import java.awt.*;
import java.awt.event.*;
class SetColor{
public static void main(String args[]){
final Frame f1 = new Frame();
f1.setBounds(300,200,500,300);
f1.setVisible(true);
f1.setLayout(null);
Button b1 = new Button("RED");
Button b2 = new Button("GREEN");
Button b3 = new Button("YELLOW");
b1.setBounds(100,140,70,30);
b2.setBounds(200,140,70,30);
b3.setBounds(300,140,70,30);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
f1.setBackground(Color.RED);
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
f1.setBackground(Color.GREEN);
}
});
b3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
f1.setBackground(Color.YELLOW);
}
});
f1.add(b1);
f1.add(b2);
f1.add(b3);
}
}