-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyFrame2.java
40 lines (28 loc) · 901 Bytes
/
MyFrame2.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
40
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class MyFrame2 extends JFrame implements java.awt.event.ActionListener {
JButton button;
JCheckBox checkBox;
MyFrame2(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 100);
button = new JButton();
button.setText("Submit");
button.addActionListener(this);
checkBox = new JCheckBox();
checkBox.setText("I'm not a robot");
checkBox.setFocusable(false);
checkBox.setFont(new Font("consolas",Font.PLAIN,35));
add(checkBox);
add(button);
setLayout(new FlowLayout());
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == button){
System.out.println(checkBox.isSelected());
}
}
}