0% found this document useful (0 votes)
10 views4 pages

2 PR

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

2 PR

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ADV JAVA (22517)

Practical No. 2: Write a program to design a form using the


components List and Choice.

Program Code
1. Write Java Program to show following output

Code=

import java.awt.*;
public class MSeasons extends Frame
{
List l;
MSeasons ()
{
setLayout(new FlowLayout());
l= new List(3);
l.add("summer");
l.add("winter");
l.add("rainy");
add(l);
}
public static void main(String args[])
{
MSeasons ms =new MSeasons();
ms.setVisible(true);
ms.setSize(500,500);
ms.setTitle("Multiple Seasons");
}
}

JAY KHANDAGALE (220348)


ADV JAVA (22517)

Practical Related Questions

1. Write the name of components used in following output

--> List,Label

2. State the difference between List and Choice control

3. Write the use of getSelectedItem() and getSelectedIndex() for List

getSelectedItem() gives you the actual value of the selected item.


getSelectedIndex() provides the index of that selected item within the list.

JAY KHANDAGALE (220348)


ADV JAVA (22517)

Exercise:
1. Develop an applet/ application using List components to add names of 10 different
cities.
import java.awt.*;
public class LCities extends Frame
{
List l;
LCities ()
{
setLayout(new FlowLayout());
l= new List(10);
l.add("PUNE");
l.add("MUMBAI");
l.add("NASHIK");
l.add("SATARA");
l.add("SANGLI");
l.add("KOLHAPUR");
l.add("SOLAPUR");
l.add("SINDHUDURG");
l.add("RAIGAD");
l.add("RATNAGIRI");
add(l);
}
public static void main(String args[])
{
LCities ms =new LCities();
ms.setVisible(true);
ms.setSize(500,500);
ms.setTitle("Multiple Seasons");
}
}

JAY KHANDAGALE (220348)


ADV JAVA (22517)

2. Develop applet / application to select multiple names of news papers


import java.awt.*;
public class LNewsPaper extends Frame
{
List l;
LNewsPaper ()
{
setLayout(new FlowLayout());
l= new List(7,true);
l.add("TIMES OF INDIA");
l.add("THE INDIAN EXPRESS");
l.add("THE HINDU");
l.add("ECONOMICS TIME");
l.add("PUNE TIMES");
l.add("SAKAL");
l.add("LOKMAT");
l.add("PUDHARI");
l.add("MAHARASHTA TIMES");
l.add("AAJ KA AANAND");
add(l);
}
public static void main(String args[])
{
LNewsPaper ln =new LNewsPaper();
ln.setVisible(true);
ln.setSize(500,500);
ln.setTitle("list of newspaper");
}
}
Output

JAY KHANDAGALE (220348)

You might also like