Monday, April 13, 2009

DropDown Menu or Choice menu

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:-



Go to
Home
JLabel
JButton
JTextField
Setting Mnemonics and shortcut keys
Setting ToolTip Icon

0 comments:

About This Blog

This Blog is all about Java and programming.This blog is written by Vaibhav Pandey .He is a Computer Science Graduate .You can contact the author at javatute@gmail.com for any suggestion or Query.You can also contact the author for advertising on this blog.All the material presented here is the property of author and its reproduction in any form is strictly prohibited.

Disclaimer:-Download links provided here are not of author in any means.These are found over the Internet.
Page copy protected against web site content infringement by Copyscape

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP