Showing posts with label sample program of choice control. Show all posts
Showing posts with label sample program of choice control. Show all posts

Tuesday, 4 March 2014

AWT CONTROLS:CHOICE CONTROLS

Choice defines only the default constructor, which creates an empty list....................

Choice controls:

       The Choice class is used to create a pop-up list of items from which the user may choose. Thus, a Choice control is a form of menu. When inactive, a Choice component takes up only enough space to show the currently selected item. When the user clicks on it, the whole list of choices pops up, and a new selection can be made. Each item in the list is a string that appears as a left-justified label in the order it is added to the Choice object. Choice defines only the default constructor, which creates an empty list.


choice control: constructors

  • Choice():   Creates a new choice menu.

choice control:methods


  • add( ):To add a selection to the list, call add( ). 

syntax:
         void add(String name)


  • getSelectedIndex():Returns the index of the currently selected item.

syntax:
         int getSelectedIndex()


  • getSelectedItem():Gets a representation of the current choice as a string.

syntax:
        string getSelectedItem()