Apr 19, 2012

List


The list class allows you to create a scrolling list of values. The list can be set up so that the user can choose either one item or multiple items.

List(int number of rows visible, boolean multiple select mode)

To create a list, first create a constructor, and then populate the choice by repeatedly calling addItem().

Example:

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

public class ListDemo extends Applet
{
    public void init()
    {
        List icecream=new List(3,true);
        icecream.add("Chocolate");
        icecream.add("Vennila");
        icecream.add("Orange");
        icecream.add("Mint chip");
        icecream.add("Rum raisin");
        add(icecream);
    }
}
/*
 * <applet code="ListDemo.class" width=300 height=150>
 * </applet>
 */

How to Execute this Example??

d:\>  javac ListDemo.java
d:\>  appletviewer ListDemo.java

Output:






0 comments :

Post a Comment