>Design an applet/application to demonstrate the use of Radio Button and
Checkbox.
import java.awt.*;
public class question1
{
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
f.setTitle("Registration Page");
f.setLayout(new FlowLayout());
Label l=new Label("Select Gender:");
f.add(l);
CheckboxGroup cr=new CheckboxGroup();
Checkbox c1=new Checkbox("Male",cr,false);
Checkbox c2=new Checkbox("Female",cr,true);
f.add(c1);
f.add(c2);
Checkbox c3=new Checkbox("I Agree");
f.add(c3);
f.setVisible(true);
}
}
Output:
MADHURA MAHESH INGAWALE 2251
>Design an applet/application to create form using Text Field,Text Area, Button
and Label
import java.awt.*;
public class question2 {
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
f.setTitle("Registration Page");
f.setLayout(new FlowLayout());
f.setVisible(true);
Label l1=new Label("Enter Name:");
f.add(l1);
TextField t1=new TextField(20);
f.add(t1);
Label l4=new Label("Enter Adress:");
f.add(l4);
TextArea t4=new TextArea(4,50);
f.add(t4);
Label l2=new Label("Enter Email:");
f.add(l2);
TextField t2=new TextField(20);
f.add(t2);
Label l3=new Label("Enter Phone no:");
f.add(l3);
TextField t3=new TextField(20);
f.add(t3);
Button b1=new Button("Submit");
f.add(b1);
}
Output:
MADHURA MAHESH INGAWALE 2251
Exercise:
1.Develop a program using Label to display message “Welcome to Java”.
import java.awt.*;
public class question3 {
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
f.setLayout(new FlowLayout());
Label l1=new Label("Welcome to Java");
f.add(l1);
f.setVisible(true);
}
}
Output:
2.Develop a program to select multiple languages known to user.(e.g
Marathi,Hindi,English,Sanskrit).
import java.awt.*;
public class question4 {
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
f.setLayout(new FlowLayout());
Label l=new Label("Select known languages");
f.add(l);
Checkbox c1=new Checkbox("Marathi");
f.add(c1);
Checkbox c2=new Checkbox("Hindi");
f.add(c2);
Checkbox c3=new Checkbox("English");
MADHURA MAHESH INGAWALE 2251
f.add(c3);
Checkbox c4=new Checkbox("Sanskrit");
f.add(c4);
f.setVisible(true);
}
}
Output:
3.Write a program to create three Buttons with Caption OK, RESET and
CANCEL.
import java.awt.*;
public class question5 {
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
// f.setTitle("Registration Page");
f.setLayout(new FlowLayout());
f.setVisible(true);
Button b1=new Button("OK");
f.add(b1);
Button b2=new Button("RESET");
f.add(b2);
Button b3=new Button("CANCEL");
f.add(b3);
}
}
Output:
MADHURA MAHESH INGAWALE 2251
MADHURA MAHESH INGAWALE 2251