Answer:
*******************************I have answered according to chegg policy.happy chegging ********************************
import java.awt.*;
import javax.swing.*;
public class Sample1 extends Frame
{
public Sample1()
{
this.setLayout(null);
Font f1 = new Font("Arial" , Font.BOLD , 12);
Font f2 = new Font("Arial" , Font.PLAIN , 12);
Label lb1 = new Label("Enemy?");
lb1.setBounds(50,100,50,80);
lb1.setFont(f1);
CheckboxGroup c1 = new CheckboxGroup();
Checkbox ch1 = new Checkbox("Player approaches", true , c1);
ch1.setBounds(100,130,120,80);
ch1.setFont(f2);
Checkbox ch2 = new Checkbox("Player runs" , false , c1);
ch2.setBounds(280,130,150,80);
ch2.setFont(f2);
Label lb2 = new Label("Health?");
lb2.setBounds(50,160,50,80);
lb2.setFont(f1);
CheckboxGroup c2 = new CheckboxGroup();
Checkbox ch3 = new Checkbox("Full", true , c2);
ch3.setBounds(100,190,50,80);
ch3.setFont(f2);
Checkbox ch4 = new Checkbox("Low" , false , c2);
ch4.setBounds(240,190,50,80);
ch4.setFont(f2);
Checkbox ch5 = new Checkbox("No" , false , c2);
ch5.setBounds(380,190,50,80);
ch5.setFont(f2);
Label lb3 = new Label("Ammo?");
lb3.setBounds(50,220,50,80);
lb3.setFont(f1);
CheckboxGroup c3 = new CheckboxGroup();
Checkbox ch6 = new Checkbox("Full", true , c3);
ch6.setBounds(100,250,50,80);
ch6.setFont(f2);
Checkbox ch7 = new Checkbox("Low" , false , c3);
ch7.setBounds(240,250,50,80);
ch7.setFont(f2);
Button btn1 = new Button("Action");
btn1.setFont(f1);
btn1.setBounds(200,335,80,30);
add(lb1);
add(ch1);
add(ch2);
add(lb2);
add(ch3);
add(ch4);
add(ch5);
add(lb3);
add(ch6);
add(ch7);
add(btn1);
}
public static void main(String ar[])
{
Sample1 s1 = new Sample1();
s1.setTitle("");
s1.setSize(500,500);
s1.setVisible(true);
}
}
Description-
Thiis is the full code of the Output. Here I have inserted Radio buttons given in the image. Here the RadioButton are at default true state. If u require u can make it false by going in the CheckboxGroup condition and make it false.
I hope it helps , Good luck for your Future....
Output-
0 Comments: