-
Notifications
You must be signed in to change notification settings - Fork 0
/
Swing6_1.java
39 lines (29 loc) · 928 Bytes
/
Swing6_1.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Swing6_1 {
public static void main(String[] args) {
Myframe frame = new Myframe();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Action Demo");
frame.setBounds(100,100,700,500);
frame.setVisible(true);
}
static class Myframe extends JFrame implements ActionListener {
Container c;
JButton b;
Myframe(){
c = this.getContentPane();
c.setLayout(null);
b= new JButton("Click me");
b.setBounds(100,100,100,20);
b.addActionListener(this);
c.add(b);
}
@Override
public void actionPerformed(ActionEvent e) {
c.setBackground(Color.YELLOW);
}
}
}