Thursday, July 8, 2010

DropDown Menu or Choice menu  

0 comments

DropDown Menu or The Choice class

A choice menu is a dropdown menu which upon clicking presents a list of menus(choices) from which user may choose one.That is when a user clicks on the choice control a list of option drops down from which a user can select only one choice.It enforces user to choose from the list of options provided.

Constructor:-

// Choice();
creating an object of Choice class
e.g. Choice choice=new Choice();

Adding Items:-

Items in the list of menu are added by using addItem(String Item) method.
e.g. choice.addItem("Option 1");




Example:-
//choice.java

import java.awt.*;

public class choice
{
public static void main(String a[])
{
Frame frm=new Frame("Choice menu demo");
Panel panel=new Panel();
Choice choice=new Choice();
frm.add(panel);
choice.addItem("Option 1");
choice.addItem("Option 2");
choice.addItem("Option 3");
choice.addItem("Option 4");
panel.add(new Label("This is DropDown MENU"));
panel.add(choice);
frm.show();
frm.pack();
frm.setBounds(100,100,250,200);
}
}

Useful Methods of Choice Class:-




What next?

You can also bookmark this post using your favorite bookmarking service:

Related Posts by Categories



Extension Factory Builder