<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.awt.Choice
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.CheckboxMenuItem.html#_top_">Previous</a>  <a href="java.awt.Color.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.awt.Choice
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----<a href="java.awt.Component.html#_top_">java.awt.Component</a>
           |
           +----java.awt.Choice
</pre>
<hr>
<dl>
  <dt> public class <b>Choice</b>
  <dt> extends <a href="java.awt.Component.html#_top_">Component</a>
  <dt> implements <a href="java.awt.ItemSelectable.html#_top_">ItemSelectable</a>
</dl>
The <code>Choice</code> class presents a pop-up menu of choices. 
 The current choice is displayed as the title of the menu. 
 <p>
 The following code example produces a pop-up menu: 
 <p>
 <hr><blockquote><pre>
 Choice ColorChooser = new Choice();
 ColorChooser.add("Green");
 ColorChooser.add("Red");
 ColorChooser.add("Blue");
 </pre></blockquote><hr>
 <p>
 After this choice menu has been added to a panel, 
 it appears as follows in its normal state:
 <p>
 <img src="images-awt/Choice-1.gif"
 ALIGN=center HSPACE=10 VSPACE=7> 
 <p>
 In the picture, <code>"Green"</code> is the current choice. 
 Pushing the mouse button down on the object causes a menu to 
 appear with the current choice highlighted. 
 <p>
<p>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Choice()"><b>Choice</b></a>()
  <dd> 
 Creates a new choice menu.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#add(java.lang.String)"><b>add</b></a>(String)
  <dd>  Adds an item to this <code>Choice</code> menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#addItem(java.lang.String)"><b>addItem</b></a>(String)
  <dd>  Adds an item to this Choice.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#addItemListener(java.awt.event.ItemListener)"><b>addItemListener</b></a>(ItemListener)
  <dd>  Adds the specified item listener to receive item events from
 this <code>Choice</code> menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#addNotify()"><b>addNotify</b></a>()
  <dd>  Creates the Choice's peer.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#countItems()"><b>countItems</b></a>()
  <dd>  
<b>Deprecated.</b>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getItem(int)"><b>getItem</b></a>(int)
  <dd>  Gets the string at the specified index in this 
 <code>Choice</code> menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getItemCount()"><b>getItemCount</b></a>()
  <dd>  Returns the number of items in this <code>Choice</code> menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSelectedIndex()"><b>getSelectedIndex</b></a>()
  <dd>  Returns the index of the currently selected item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSelectedItem()"><b>getSelectedItem</b></a>()
  <dd>  Gets a representation of the current choice as a string.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSelectedObjects()"><b>getSelectedObjects</b></a>()
  <dd>  Returns an array (length 1) containing the currently selected
 item.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#insert(java.lang.String, int)"><b>insert</b></a>(String, int)
  <dd>  Inserts the item into this choice at the specified position.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#paramString()"><b>paramString</b></a>()
  <dd>  Returns the parameter string representing the state of this 
 choice menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#processEvent(java.awt.AWTEvent)"><b>processEvent</b></a>(AWTEvent)
  <dd>  Processes events on this choice.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#processItemEvent(java.awt.event.ItemEvent)"><b>processItemEvent</b></a>(ItemEvent)
  <dd> 
 Processes item events occurring on this <code>Choice</code> 
 menu by dispatching them to any registered 
 <code>ItemListener</code> objects.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#remove(int)"><b>remove</b></a>(int)
  <dd>  Removes an item from the choice menu 
 at the specified position.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#remove(java.lang.String)"><b>remove</b></a>(String)
  <dd>  Remove the first occurrence of <code>item</code> 
 from the <code>Choice</code> menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#removeAll()"><b>removeAll</b></a>()
  <dd>  Removes all items from the choice menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#removeItemListener(java.awt.event.ItemListener)"><b>removeItemListener</b></a>(ItemListener)
  <dd>  Removes the specified item listener so that it no longer receives 
 item events from this <code>Choice</code> menu.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#select(int)"><b>select</b></a>(int)
  <dd>  Sets the selected item in this <code>Choice</code> menu to be the 
 item at the specified position.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#select(java.lang.String)"><b>select</b></a>(String)
  <dd>  Sets the selected item in this <code>Choice</code> menu 
 to be the item whose name is equal to the specified string.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="Choice"></a>
<a name="Choice()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Choice</b>
<pre>
 public Choice()
</pre>
<dl>
  <dd> Creates a new choice menu. The menu initially has no items in it. 
 <p>
 By default, the first item added to the choice menu becomes the 
 selected item, until a different selection is made by the user  
 by calling one of the <code>select</code> methods.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#select(int)">select</a>, <a href="#select(java.lang.String)">select</a>
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="addNotify()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="addNotify"><b>addNotify</b></a>
<pre>
 public void addNotify()
</pre>
<dl>
  <dd> Creates the Choice's peer.  This peer allows us to change the look
 of the Choice without changing its functionality.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.awt.Component.html#addNotify()">addNotify</a> in class <a href="java.awt.Component.html#_top_">Component</a>
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.Toolkit.html#createChoice(java.awt.Choice)">createChoice</a>, <a href="java.awt.Component.html#getToolkit()">getToolkit</a>
  </dl></dd>
</dl>
<a name="getItemCount()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getItemCount"><b>getItemCount</b></a>
<pre>
 public int getItemCount()
</pre>
<dl>
  <dd> Returns the number of items in this <code>Choice</code> menu.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#getItem">getItem</a>
  </dl></dd>
</dl>
<a name="countItems()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="countItems"><b>countItems</b></a>
<pre>
 public int countItems()
</pre>
<dl>
<dd><b> Note: countItems() is deprecated.</b>
<i>As of JDK version 1.1,
 replaced by <code>getItemCount()</code>.</i>
<p>
</dl>
<a name="getItem(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getItem"><b>getItem</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> getItem(int index)
</pre>
<dl>
  <dd> Gets the string at the specified index in this 
 <code>Choice</code> menu.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> index - the index at which to begin.
    <dt> <b>See Also:</b>
    <dd> <a href="#getItemCount">getItemCount</a>
  </dl></dd>
</dl>
<a name="add(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="add"><b>add</b></a>
<pre>
 public void add(<a href="java.lang.String.html#_top_">String</a> item)
</pre>
<dl>
  <dd> Adds an item to this <code>Choice</code> menu.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> item - the item to be added
    <dt> <b>Throws:</b> <a href="java.lang.NullPointerException.html#_top_">NullPointerException</a>
    <dd> if the item's value is <code>null</code>.
  </dl></dd>
</dl>
<a name="addItem(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="addItem"><b>addItem</b></a>
<pre>
 public synchronized void addItem(<a href="java.lang.String.html#_top_">String</a> item)
</pre>
<dl>
  <dd> Adds an item to this Choice.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> item - the item to be added
    <dt> <b>Throws:</b> <a href="java.lang.NullPointerException.html#_top_">NullPointerException</a>
    <dd> If the item's value is equal to null.
  </dl></dd>
</dl>
<a name="insert(java.lang.String, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="insert"><b>insert</b></a>
<pre>
 public synchronized void insert(<a href="java.lang.String.html#_top_">String</a> item,
                                 int index)
</pre>
<dl>
  <dd> Inserts the item into this choice at the specified position.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> item - the item to be inserted
    <dd> index - the position at which the item should be inserted
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if index is less than 0.
  </dl></dd>
</dl>
<a name="remove(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="remove"><b>remove</b></a>
<pre>
 public synchronized void remove(<a href="java.lang.String.html#_top_">String</a> item)
</pre>
<dl>
  <dd> Remove the first occurrence of <code>item</code> 
 from the <code>Choice</code> menu.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> item - the item to remove from this <code>Choice</code> menu.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the item doesn't
                     exist in the choice menu.
  </dl></dd>
</dl>
<a name="remove(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="remove"><b>remove</b></a>
<pre>
 public synchronized void remove(int position)
</pre>
<dl>
  <dd> Removes an item from the choice menu 
 at the specified position.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> position - the position of the item.
  </dl></dd>
</dl>
<a name="removeAll()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="removeAll"><b>removeAll</b></a>
<pre>
 public synchronized void removeAll()
</pre>
<dl>
  <dd> Removes all items from the choice menu.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#remove">remove</a>
  </dl></dd>
</dl>
<a name="getSelectedItem()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSelectedItem"><b>getSelectedItem</b></a>
<pre>
 public synchronized <a href="java.lang.String.html#_top_">String</a> getSelectedItem()
</pre>
<dl>
  <dd> Gets a representation of the current choice as a string.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> a string representation of the currently
                     selected item in this choice menu.
    <dt> <b>See Also:</b>
    <dd> <a href="#getSelectedIndex">getSelectedIndex</a>
  </dl></dd>
</dl>
<a name="getSelectedObjects()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSelectedObjects"><b>getSelectedObjects</b></a>
<pre>
 public synchronized <a href="java.lang.Object.html#_top_">Object</a>[] getSelectedObjects()
</pre>
<dl>
  <dd> Returns an array (length 1) containing the currently selected
 item.  If this choice has no items, returns null.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.ItemSelectable.html#_top_">ItemSelectable</a>
  </dl></dd>
</dl>
<a name="getSelectedIndex()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSelectedIndex"><b>getSelectedIndex</b></a>
<pre>
 public int getSelectedIndex()
</pre>
<dl>
  <dd> Returns the index of the currently selected item.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#getSelectedItem">getSelectedItem</a>
  </dl></dd>
</dl>
<a name="select(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="select"><b>select</b></a>
<pre>
 public void select(int pos)
</pre>
<dl>
  <dd> Sets the selected item in this <code>Choice</code> menu to be the 
 item at the specified position.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> pos - the positon of the selected item.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the specified
                            position is invalid.
    <dt> <b>See Also:</b>
    <dd> <a href="#getSelectedItem">getSelectedItem</a>, <a href="#getSelectedIndex">getSelectedIndex</a>
  </dl></dd>
</dl>
<a name="select(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="select"><b>select</b></a>
<pre>
 public synchronized void select(<a href="java.lang.String.html#_top_">String</a> str)
</pre>
<dl>
  <dd> Sets the selected item in this <code>Choice</code> menu 
 to be the item whose name is equal to the specified string. 
 If more than one item matches (is equal to) the specified string, 
 the one with the smallest index is selected.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> str - the specified string
    <dt> <b>See Also:</b>
    <dd> <a href="#getSelectedItem">getSelectedItem</a>, <a href="#getSelectedIndex">getSelectedIndex</a>
  </dl></dd>
</dl>
<a name="addItemListener(java.awt.event.ItemListener)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="addItemListener"><b>addItemListener</b></a>
<pre>
 public synchronized void addItemListener(<a href="java.awt.event.ItemListener.html#_top_">ItemListener</a> l)
</pre>
<dl>
  <dd> Adds the specified item listener to receive item events from
 this <code>Choice</code> menu.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> l - the item listener.
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.event.ItemEvent.html#_top_">ItemEvent</a>, <a href="java.awt.event.ItemListener.html#_top_">ItemListener</a>, <a href="#removeItemListener">removeItemListener</a>
  </dl></dd>
</dl>
<a name="removeItemListener(java.awt.event.ItemListener)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="removeItemListener"><b>removeItemListener</b></a>
<pre>
 public synchronized void removeItemListener(<a href="java.awt.event.ItemListener.html#_top_">ItemListener</a> l)
</pre>
<dl>
  <dd> Removes the specified item listener so that it no longer receives 
 item events from this <code>Choice</code> menu.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> l - the item listener.
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.event.ItemEvent.html#_top_">ItemEvent</a>, <a href="java.awt.event.ItemListener.html#_top_">ItemListener</a>, <a href="#addItemListener">addItemListener</a>
  </dl></dd>
</dl>
<a name="processEvent(java.awt.AWTEvent)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="processEvent"><b>processEvent</b></a>
<pre>
 protected void processEvent(<a href="java.awt.AWTEvent.html#_top_">AWTEvent</a> e)
</pre>
<dl>
  <dd> Processes events on this choice. If the event is an 
 instance of <code>ItemEvent</code>, it invokes the 
 <code>processItemEvent</code> method. Otherwise, it calls its
 superclass's <code>processEvent</code> method.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> e - the event.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.awt.Component.html#processEvent(java.awt.AWTEvent)">processEvent</a> in class <a href="java.awt.Component.html#_top_">Component</a>
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.event.ItemEvent.html#_top_">ItemEvent</a>, <a href="#processItemEvent">processItemEvent</a>
  </dl></dd>
</dl>
<a name="processItemEvent(java.awt.event.ItemEvent)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="processItemEvent"><b>processItemEvent</b></a>
<pre>
 protected void processItemEvent(<a href="java.awt.event.ItemEvent.html#_top_">ItemEvent</a> e)
</pre>
<dl>
  <dd> Processes item events occurring on this <code>Choice</code> 
 menu by dispatching them to any registered 
 <code>ItemListener</code> objects. 
 <p>
 This method is not called unless item events are 
 enabled for this component. Item events are enabled 
 when one of the following occurs:
 <p><ul>
 <li>An <code>ItemListener</code> object is registered 
 via <code>addItemListener</code>.
 <li>Item events are enabled via <code>enableEvents</code>.
 </ul>
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> e - the item event.
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.event.ItemEvent.html#_top_">ItemEvent</a>, <a href="java.awt.event.ItemListener.html#_top_">ItemListener</a>, <a href="#addItemListener">addItemListener</a>, <a href="java.awt.Component.html#enableEvents">enableEvents</a>
  </dl></dd>
</dl>
<a name="paramString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="paramString"><b>paramString</b></a>
<pre>
 protected <a href="java.lang.String.html#_top_">String</a> paramString()
</pre>
<dl>
  <dd> Returns the parameter string representing the state of this 
 choice menu. This string is useful for debugging.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the parameter string of this <code>Choice</code> menu.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.awt.Component.html#paramString()">paramString</a> in class <a href="java.awt.Component.html#_top_">Component</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.CheckboxMenuItem.html#_top_">Previous</a>  <a href="java.awt.Color.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
