0% found this document useful (0 votes)
17 views5 pages

Experiment No. 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

1) Develop a Applet/ Application using list components to add name of 10 different cities.

Program Code :-

import java.applet.Applet;
import java.awt.*;

/* <applet code="Ex2_2.class" width="300" height="300">


</applet> */

public class Ex2_2 extends Applet


{
public void init()
{
List li2;
li2=new List(10);
li2.add("New Delhi");
li2.add("Mumbai",1);
li2.add("Pune",2);
li2.add("Sangli",2);
li2.add("Kolhapur",2);
li2.add("Satara",2);
li2.add("Nashik",2);
li2.add("Palus",2);
li2.add("Ahamadabad",2);
li2.add("Nagpur",2);
add(li2);
}
}
Output :-
2) Develop a Applet /Application to select multiple names of newspapers.

Program Code :-

import java.applet.Applet;
import java.awt.*;

/* <applet code="Ex2_3.class" width="300" height="300">


</applet> */

public class Ex2_3 extends Applet


{
public void init()
{
List li2;
li2=new List(5,true);
li2.add("Times Of India");
li2.add("Lokmat",1);
li2.add("Pudhari",2);
li2.add("Punya Nagari",2);
li2.add("Indian Express",2);
add(li2);
}
}
Output :-
3) Develop an applet to create Label, Button , Checkbox Group, TextField, TextArea, List and
Choice
Program Code :-

import java.applet.*;
import java.awt.*;

/* <applet code="Form.class" width="500" height="500">


</applet> */

public class Form extends Applet


{
public void init()
{
setLayout(null);
Label l;
l=new Label("Name :- ");
l.setBounds(20,20,50,50);
add(l);

TextField t1;
t1=new TextField();
t1.setBounds(135,35,200,35);
add(t1);

Label l1;
l1=new Label("Address :- ");
l1.setBounds(20,90,50,50);
add(l1);

TextArea t2;
t2=new TextArea();
t2.setBounds(135,105,200,75);
add(t2);

Label l2;
l2=new Label("Gender :- ");
l2.setBounds(20,180,50,50);
add(l2);

Checkbox chb1,chb2;
CheckboxGroup cb1;
cb1=new CheckboxGroup();
chb1=new Checkbox("Male",false,cb1);
chb1.setBounds(135,180,50,50);
add(chb1);
chb2=new Checkbox("Female",cb1,true);
chb2.setBounds(285,180,70,50);
add(chb2);

Label l3;
l3=new Label("Languages :- ");
l3.setBounds(20,220,70,50);
add(l3);

List li3;
li3=new List(3,true);
li3.add("Marathi");
li3.add("Hindi",1);
li3.add("English",2);
li3.add("Sanskrit",3);
li3.setBounds(135,235,70,70);
add(li3);

Label l4;
l4=new Label("Age :- ");
l4.setBounds(20,305,50,50);
add(l4);

Choice ch2;
ch2=new Choice();
ch2.add("16");
ch2.add("17");
ch2.add("18");
ch2.add("19");
ch2.add("20");
ch2.add("21");
ch2.add("22");
ch2.setBounds(135,310,70,70);
add(ch2);

Button b1;
b1=new Button("Submit");
b1.setBounds(65,360,70,40);
add(b1);
}
}
Output :-

You might also like