Name: Manish Kumhar Class: Tyco-A Roll No: 43 Subject: Ajp (Experiment: 2)
Name: Manish Kumhar Class: Tyco-A Roll No: 43 Subject: Ajp (Experiment: 2)
CLASS: TYCO-A
ROLL NO: 43
SUBJECT: AJP (EXPERIMENT: 2)
Practical No. 2: Write a program to design a form using the
components List and Choice.
I. Practical Significance:
The List and Choice components lets the user choose one option from list of available options A
Choice is displayed in a compact form that requires you to pull it down to see the list of available
choices. Only one item may be selected from a Choice. A List may be displayed in such a way that
several List items are visible. A List supports the selection of one or more List items.
List: Creates a list from which the user can choose list items.
Constructors:
List () // allows only one item to be selected
List (int numRows) // no of entries will always be visible
List (int numRows, Boolean multiple Select)// if it is true then user select multiple
items. If it is false then only one item may be selected
Choice
The Choice class is used to create a pop-up list of items from which the user may choose.
When the user clicks on it, the whole list of choices pops up and new selection can be made.
Choice defines the default constructor, which creates an empty list. To add a selection to the
list, call add ().
Nil
Sr. Name of
Broad Specification Quantity Remarks (If any)
No. Resource
1
2
X. Program Code: Teacher must assign a separate program statement to group of 3-4 students.
1. Write Java Program to show following output.
Figure 1
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
......................................................................................
Program:-
import java.awt.*;
public class Season
{
Season() {
Frame f = new Frame("Manish Kumhar 43");
List l1 = new List(3, true);
l1.setBounds(100, 70, 100, 70);
l1.add("Summer");
l1.add("Winter");
l1.add("Rainy");
f.add(l1);
f.setSize(300,200);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
Season s = new Season();
}
}
Output:-
XII. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design more such
questions so as to ensure the achievement of identified CO.
1. Write the name of components used in following output
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
XIII. Exercise:
1. Develop an applet/ application using List components to add names of 10 different cities.
Program:-
import java.awt.*;
public class Cities
{
Cities()
{
Frame f = new Frame("Manish Kumhar 43");
List l1 = new List(5);
l1.setBounds(100, 100, 100, 120);
l1.add("Mumbai");
l1.add("Bangalore");
l1.add("Delhi");
l1.add("Hyderabad");
l1.add("Ahmedabad");
l1.add("Jaipur");
l1.add("Chennai");
l1.add("Nagpur");
l1.add("Thane");
l1.add("Pune");
f.add(l1);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
Cities s = new Cities();
}
}
Output:-
2. Develop applet / application to select multiple names of news papers
Program:-
import java.awt.*;
public class NewsPaper
{
NewsPaper()
{
Frame f = new Frame("Manish Kumhar 43");
List l1 = new List(7,true);
l1.setBounds(100, 100, 100, 120);
l1.add("Times Of India");
l1.add("Hindustan Times");
l1.add("The Telegraph");
l1.add("Deccan Chronicle");
l1.add("Mumbai Mirror");
l1.add("The New India Express");
l1.add("The Economic Times");
f.add(l1);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
NewsPaper s = new NewsPaper();
}
}
Output:-
XIV. References/ Suggestions for Further Reading
1. https://www.javatpoint.com
2. https://www.tutorialspoint.com/java
3. The complete reference Java 2 by Herbert schildt
1. …………………………………..
2. …………………………………..
3. …………………………………..
Dated signature of
Marks Obtained
Teacher
Process Product
Total(50)
Related(35) Related(15)