-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnikhitlight.java
36 lines (32 loc) · 1.18 KB
/
nikhitlight.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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class nikhitlight {
nikhitlight(){
JFrame f = new JFrame("*****Nikhit Lights*****");
JButton a = new JButton("red");
a.setBackground(Color.WHITE);
JButton b = new JButton("green");
b.setBackground(Color.WHITE);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400,100);
f.setVisible(true);
f.add(a);f.add(b);
f.setLayout(new GridLayout(1,2));
a.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
a.setBackground(Color.RED);
b.setBackground(Color.WHITE);
}
});
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
a.setBackground(Color.WHITE);
b.setBackground(Color.GREEN);
}
});
}
public static void main(String[]args){
new nikhitlight();
}
}