All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.bwt.JCComboBox

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----jclass.bwt.JCContainer
                                   |
                                   +----jclass.bwt.JCComboBox

public class JCComboBox
extends JCContainer
implements KeyListener, JCListListener, JCActionListener, JCItemSelectable, JCChoiceInterface, JCTextManagerInterface
JCComboBox provides the capabilities of a JCTextField and a JCList component. It allows users to perform operations like typing and pasting information, and it also provides a list of possible choices that the user can select from to complete the TextField entry.

Note that on MS-Windows, AWT currently uses a Windows ComboBox as the peer for its Choice component. JCComboBox provides this functionality on all platforms.

The list may be displayed at all times, or may only drop down when the user presses an arrow button next to the TextField (a "drop-down" ComboBox).

Behavior
If the arrow button is pressed and released, the list pops up and stays up until the user clicks an item inside it, hits RETURN, clicks outside the list, or presses ESCAPE. If an item is clicked or RETURN is hit, the item is copied to the text field.

Properties

Name Method
Background setBackground
Font setFont
Foreground setForeground
Items setItems
Insets setInsets
PreferredSize setPreferredSize
Style setStyle
Text setText
UserData setUserData
VisibleRows setVisibleRows

Events

Class Listener Description
JCActionEvent addActionListener Called when the ENTER key is hit
JCItemEvent addItemListener Cafter the user selects an item
JCComboBoxEvent addComboBoxListener Called before the list is displayed, and after the user has made a selection


Variable Index

 o actionListeners
List of JCActionEvent listeners
 o BEGIN
 o COMBOBOX_DROPDOWN
 o COMBOBOX_DROPDOWN_LIST
 o COMBOBOX_SIMPLE
 o END
 o itemListeners
List of JCItemEvent listeners
 o list_poppedup
Set to true when non-COMBOBOX_SIMPLE list is displayed.
 o listeners
List of JCComboBoxEvent listeners

Constructor Index

 o JCComboBox()
Creates an empty ComboBox.
 o JCComboBox(JCVector)
Creates an empty ComboBox with the specified list items.
 o JCComboBox(JCVector, Applet, String)
Creates a comboBox which reads parameters from the applet's HTML file.
 o JCComboBox(String[], String)
Creates a comboBox with the specified items and name.

Method Index

 o actionPerformed(JCActionEvent)
If the arrow button was clicked, calls showListAction to display the list.
If the list is displayed and the RETURN key was hit, calls setTextAction to copy the selected item to the text field.
 o add(String)
Adds an item to the list.
 o addActionListener(JCActionListener)
Adds the specified action listener to receive JCTextField action events.
 o addComboBoxListener(JCComboBoxListener)
Adds the specified JCComboBoxEvent listener to receive events.
 o addItemListener(JCItemListener)
Adds the specified item listener to receive item selection events.
 o addNotify()
Creates the Panel's peer.
 o getButton()
Gets the button component.
 o getItem(int)
Returns the item at the specified index in the list.
 o getItemCount()
Returns the number of items in the list.
 o getItems()
Gets the list's values as a list of Strings.
 o getList()
Gets the list component.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o getSelectedIndex()
Returns the index of the currently selected item.
 o getSelectedIndexes()
Returns an array (length 1) containing the currently selected item.
 o getSelectedItem()
Returns a String representation of the current choice.
 o getSelectedObjects()
Returns an array (length 1) containing the currently selected item.
 o getStyle()
Gets the Style value.
 o getText()
Gets the value of the text.
 o getTextComponent()
Gets the component to be used as the data entry field as an object which supports the JCTextInterface
 o getTextField()
Gets the component to be used as the data entry field.
 o itemStateChanged(JCItemEvent)
JCItemListener method - no-op
 o keyPressed(KeyEvent)
 o keyReleased(KeyEvent)
 o keyTyped(KeyEvent)
 o layout()
 o listItemSelectBegin(JCListEvent)
JCListListener method - no-op
 o listItemSelectEnd(JCListEvent)
If the user clicked an item, calls setTextAction to copy the item to the text field.
 o paintInterior(Graphics)
Draws the shadows and title.
 o postComboBoxEvent(int, Object)
Posts a JCComboBoxEvent
 o preferredHeight()
Gets the subclass' preferred height (default: 100).
 o preferredWidth()
Gets the subclass' preferred width (default: 100).
 o remove(String)
Removes the first occurrence of an item from the list.
 o removeActionListener(JCActionListener)
Removes the specified action listener so it no longer receives action events.
 o removeAll()
Removes all items from the list.
 o removeComboBoxListener(JCComboBoxListener)
Removes the specified listener so it no longer receives JCComboBoxEvents.
 o removeItemListener(JCItemListener)
Removes the specified item listener so it no longer receives item events.
 o select(int)
Selects the item with the specified postion.
 o select(Object)
Selects the specified item.
 o setItems(String[])
Sets the list's values as a list of Strings.
 o setLayout(LayoutManager)
Sets the layout manager for this container.
 o setStyle(int)
Sets the style, which specifies whether the list is always displayed and whether the text field is editable.
 o setText(String)
Sets the text field's value to the specified string.

HTML param name/value: "Text"/string

 o setTextAction(String)
Copies the item to the text field, after first posting a JCComboBoxEvent to allow the application to disallow the selection or change its value.
 o setVisibleRows(int)
Sets the number of visible rows; if set to 0 (default), the list will attempt to resize itself so that all its items are visible.

HTML param name/value: "VisibleRows"/int

 o showListAction(JCActionEvent)
Displays the list if it is not visible.

Variables

 o COMBOBOX_SIMPLE
 public static final int COMBOBOX_SIMPLE
 o COMBOBOX_DROPDOWN
 public static final int COMBOBOX_DROPDOWN
 o COMBOBOX_DROPDOWN_LIST
 public static final int COMBOBOX_DROPDOWN_LIST
 o list_poppedup
 protected boolean list_poppedup
Set to true when non-COMBOBOX_SIMPLE list is displayed.

 o itemListeners
 protected JCVector itemListeners
List of JCItemEvent listeners

 o actionListeners
 protected JCVector actionListeners
List of JCActionEvent listeners

 o listeners
 protected JCVector listeners
List of JCComboBoxEvent listeners

 o BEGIN
 protected static final int BEGIN
 o END
 protected static final int END

Constructors

 o JCComboBox
 public JCComboBox()
Creates an empty ComboBox. No parameters are read from an HTML file.

 o JCComboBox
 public JCComboBox(JCVector items)
Creates an empty ComboBox with the specified list items.

 o JCComboBox
 public JCComboBox(String items[],
                   String name)
Creates a comboBox with the specified items and name. No parameters are read from an HTML file.

 o JCComboBox
 public JCComboBox(JCVector items,
                   Applet applet,
                   String name)
Creates a comboBox which reads parameters from the applet's HTML file.

Parameters:
applet - the applet whose PARAM tags are to be read
name - if this is not null, only parameters preceded by this name are read
See Also:
getParameter

Methods

 o getParameters
 protected void getParameters()
Reads the parameter values from the HTML page using the component's applet. The values will override those previously set.

Overrides:
getParameters in class JCContainer
 o getTextField
 public JCTextField getTextField()
Gets the component to be used as the data entry field.

 o getTextComponent
 public synchronized JCTextInterface getTextComponent()
Gets the component to be used as the data entry field as an object which supports the JCTextInterface

See Also:
getTextField
 o getList
 public JCList getList()
Gets the list component.

 o getButton
 public JCArrowButton getButton()
Gets the button component.

 o setText
 public synchronized void setText(String s)
Sets the text field's value to the specified string.

HTML param name/value: "Text"/string

 o getText
 public synchronized String getText()
Gets the value of the text.

See Also:
setText
 o setItems
 public synchronized void setItems(String items[])
Sets the list's values as a list of Strings.

 o getItems
 public synchronized String[] getItems()
Gets the list's values as a list of Strings.

See Also:
setItems
 o getStyle
 public int getStyle()
Gets the Style value.

See Also:
setStyle
 o setStyle
 public void setStyle(int v)
Sets the style, which specifies whether the list is always displayed and whether the text field is editable. If the list is hidden, it can be displayed by pressing the arrow button or hitting the down or up arrow key. The value must be one of the following values:
 COMBOBOX_SIMPLE           list is always displayed, text field is editable
 COMBOBOX_DROPDOWN         list is hidden, text field is editable (default)
 COMBOBOX_DROPDOWN_LIST    list is hidden, text field is uneditable
 

Throws: IllegalArgumentException
If an invalid value is set
 o getItemCount
 public int getItemCount()
Returns the number of items in the list.

See Also:
getItem
 o getItem
 public Object getItem(int index)
Returns the item at the specified index in the list.

See Also:
getItemCount
 o add
 public synchronized void add(String item)
Adds an item to the list.

Throws: NullPointerException
If the item's value is null.
 o remove
 public synchronized void remove(String item)
Removes the first occurrence of an item from the list.

Throws: IllegalArgumentException
If the item doesn't exist
 o removeAll
 public synchronized void removeAll()
Removes all items from the list.

Overrides:
removeAll in class Container
See Also:
remove
 o getSelectedItem
 public synchronized String getSelectedItem()
Returns a String representation of the current choice.

See Also:
getSelectedIndex
 o getSelectedIndex
 public int getSelectedIndex()
Returns the index of the currently selected item.

See Also:
getSelectedItem
 o select
 public synchronized void select(int pos)
Selects the item with the specified postion.

Throws: IllegalArgumentException
If the choice item position is invalid.
See Also:
getSelectedItem, getSelectedIndex
 o select
 public synchronized void select(Object item)
Selects the specified item.

See Also:
getSelectedItem, getSelectedIndex
 o getSelectedObjects
 public synchronized Object[] getSelectedObjects()
Returns an array (length 1) containing the currently selected item.

See Also:
JCItemSelectable, getSelectedIndex
 o getSelectedIndexes
 public synchronized int[] getSelectedIndexes()
Returns an array (length 1) containing the currently selected item.

See Also:
JCItemSelectable
 o setVisibleRows
 public void setVisibleRows(int v)
Sets the number of visible rows; if set to 0 (default), the list will attempt to resize itself so that all its items are visible.

HTML param name/value: "VisibleRows"/int

See Also:
setItems
 o addComboBoxListener
 public void addComboBoxListener(JCComboBoxListener l)
Adds the specified JCComboBoxEvent listener to receive events.

See Also:
JCComboBoxEvent
 o removeComboBoxListener
 public void removeComboBoxListener(JCComboBoxListener l)
Removes the specified listener so it no longer receives JCComboBoxEvents.

See Also:
addComboBoxListener
 o addActionListener
 public void addActionListener(JCActionListener l)
Adds the specified action listener to receive JCTextField action events.

See Also:
JCActionEvent
 o removeActionListener
 public void removeActionListener(JCActionListener l)
Removes the specified action listener so it no longer receives action events.

See Also:
addActionListener
 o addItemListener
 public void addItemListener(JCItemListener l)
Adds the specified item listener to receive item selection events.

See Also:
JCItemEvent, JCItemListener
 o removeItemListener
 public void removeItemListener(JCItemListener l)
Removes the specified item listener so it no longer receives item events.

 o preferredWidth
 protected int preferredWidth()
Gets the subclass' preferred width (default: 100).

Overrides:
preferredWidth in class JCContainer
 o preferredHeight
 protected int preferredHeight()
Gets the subclass' preferred height (default: 100).

Overrides:
preferredHeight in class JCContainer
 o addNotify
 public void addNotify()
Creates the Panel's peer.

Overrides:
addNotify in class JCContainer
 o layout
 public synchronized void layout()
Overrides:
layout in class Container
 o showListAction
 public void showListAction(JCActionEvent ev)
Displays the list if it is not visible. A JCComboBoxEvent is first posted.

 o setTextAction
 protected void setTextAction(String value)
Copies the item to the text field, after first posting a JCComboBoxEvent to allow the application to disallow the selection or change its value. After the value is copied, an JCItemEvent is posted.

See Also:
addComboBoxListener, addItemListener
 o postComboBoxEvent
 protected JCComboBoxEvent postComboBoxEvent(int stage,
                                             Object value)
Posts a JCComboBoxEvent

Returns:
the posted event, or null if there are no listeners
See Also:
addComboBoxListener, JCComboBoxEvent
 o itemStateChanged
 public void itemStateChanged(JCItemEvent ev)
JCItemListener method - no-op

 o keyPressed
 public void keyPressed(KeyEvent ev)
 o keyReleased
 public void keyReleased(KeyEvent ev)
 o keyTyped
 public void keyTyped(KeyEvent ev)
 o actionPerformed
 public void actionPerformed(JCActionEvent ev)
If the arrow button was clicked, calls showListAction to display the list.
If the list is displayed and the RETURN key was hit, calls setTextAction to copy the selected item to the text field.

See Also:
showListAction, setTextAction
 o listItemSelectBegin
 public void listItemSelectBegin(JCListEvent ev)
JCListListener method - no-op

 o listItemSelectEnd
 public void listItemSelectEnd(JCListEvent ev)
If the user clicked an item, calls setTextAction to copy the item to the text field.

See Also:
setTextAction
 o setLayout
 public final void setLayout(LayoutManager mgr)
Sets the layout manager for this container. This method is overridden to prevent the layout mgr from being set.

Overrides:
setLayout in class Container
 o paintInterior
 public void paintInterior(Graphics gc)
Draws the shadows and title.

Overrides:
paintInterior in class JCContainer

All Packages  Class Hierarchy  This Package  Previous  Next  Index