forked from jvm-coder/Java_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyCheckbox.java
More file actions
executable file
·39 lines (31 loc) · 1.13 KB
/
Copy pathMyCheckbox.java
File metadata and controls
executable file
·39 lines (31 loc) · 1.13 KB
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 java.awt.*;
class HomeFrame extends Frame{
HomeFrame(String title) {
setTitle(title);
setSize(420, 420);
}
}
public class MyCheckbox {
public static void main(String[] args) {
Frame frame = new HomeFrame("MyCheckbox.java");
Image icon = Toolkit.getDefaultToolkit().getImage("../icon.png");
frame.setIconImage(icon);
Panel panel = new Panel();
frame.add(panel);
Checkbox checkbox1 = new Checkbox(); // Constructor 1
checkbox1.setLabel("Checkbox 1"); // Method 1
checkbox1.setState(false); // Method 2
panel.add(checkbox1);
Checkbox checkbox2 = new Checkbox("Checkbox 2"); // Constructor 2
checkbox2.setState(true); // Method 2
panel.add(checkbox2);
Checkbox checkbox3 = new Checkbox("Checkbox 3", false); // Constructor 3
panel.add(checkbox3);
frame.setVisible(true);
System.out.println("Label\t\tState");
System.out.println(checkbox1.getLabel() + "\t" + checkbox1.getState()); // Method 4 and 5
System.out.println(checkbox2.getLabel() + "\t" + checkbox2.getState()); // Method 4 and 5
System.out.println(checkbox3.getLabel() + "\t" + checkbox3.getState()); // Method 4 and 5
}
}
// ItemEvent