All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.ComboBox

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----symantec.itools.awt.ComboBox

public class ComboBox
extends Panel
A ComboBox is a text field with an attached drop-down list box. It may be user-editable, "searchable", have horizontal and/or vertical scroll bars, and can use different fonts for the text box and the drop-down list. Also each list box item can have an image in addition to text. A user-editable ComboBox allows the user to enter any desired text into the text field. A searchable ComboBox allows the user to enter text into the text field as long as it matches one of the existing list items. This allows the user to select from a non-editable list by typing instead of dropping-down the list and selecting with the mouse.

Use a ComboBox to:


Variable Index

 o EVT_IMAGE_SELECT
The ID of the event posted when the image part of a drop-down list item is selected.

Constructor Index

 o ComboBox()
Constructs a new default ComboBox.
 o ComboBox(boolean, boolean)
Constructs a new editable and/or searchable ComboBox.

Method Index

 o addFirstTopDown()
Determines whether the ComboBox should be the first component added to its container, or the last.
 o addItem(Image, String)
Adds the specified item with an image to the end of the drop-down list and enables it.
 o addItem(Image, String, boolean)
Adds the specified item with an image to the end of drop-down the list and conditionally enables it.
 o addItem(String)
Adds the specified item to the end of the drop-down list and enables the item.
 o addItem(String, boolean)
Adds the specified item to the end of the drop-down list and conditionally enables it.
 o addLastBottomUp()
Determines whether the ComboBox should be the last component added to its container, or the first.
 o changeImage(int, Image)
Changes the image associated with a drop-down list item.
 o changeText(int, String)
Changes the text associated with a drop-down list item.
 o clear()
Clears all items from the drop-down list.
 o countItems()
Returns the total number of items in the drop-down list.
 o delItem(int)
Deletes an item from the drop-down list.
 o delItems(int, int)
Deletes multiple items from the drop-down list.
 o delSelectedItem()
Deletes the currently selected item from the list.
 o deselect(int)
Deselects the drop-down list item at the specified zero-relative index.
 o disable(int)
Disables a drop-down list item at a given zero-relative index.
 o dropList(boolean)
Handles dropping and "un-dropping" the ComboBox list.
 o enable(int)
Enables a drop-down list item at a given zero-relative index.
 o enable(int, boolean)
Conditionally enables a drop-down list item at a given zero-relative index.
 o getCaseSensitive()
Returns the current ComboBox case-sensitive search status.
 o getComboBoxFont()
Returns the current edit field and drop-down list font.
 o getDropDownFont()
Returns the current drop-down list font.
 o getEditable()
Gets whether the ComboBox is user-editable.
 o getEditFieldFont()
Returns the current edit field font.
 o getItem(int)
Returns the drop-down list item at the specified zero-relative index.
 o getListItems()
Returns the current list as an array.
 o getSearchable()
Returns the current ComboBox "searchable" status.
 o getSelectedIndex()
Gets the zero-relative index of the currently selected item in the drop-down list.
 o getSelectedItem()
Returns the selected item on the drop-down list.
 o getShowHorizontalScroll()
Gets the current horizontal scrollbar display option.
 o getShowVerticalScroll()
Gets the current vertical scrollbar display option.
 o getText()
Returns the text in the edit field portion of the ComboBox, unless the ComboBox is not editable.
 o handleEvent(Event)
Processes events for this component.
 o isSelected(int)
Returns the selection state of the list item at the given zero-relative index.
 o minimumSize()
Returns the minimum dimensions to properly display this component.
 o needsPlatformHelp()
Use this method to set a flag for use in your handleEvent to determine if the ComboBox needs help in "un-dropping".
 o paint(Graphics)
Paints this component using the given graphics context.
 o preferredSize()
Returns the recommended dimensions to properly display this component.
 o reshape(int, int, int, int)
Moves and/or resizes this component.
 o select(int)
Selects the drop-down list item with the specified zero-relative index.
 o select(String)
Selects the first drop-down item in the list which has exactly matching text.
 o setCaseSensitive(boolean)
Conditionally sets the ComboBox to be case-sensitive during searches.
 o setComboBoxFont(Font)
Sets the edit field and drop-down list font.
 o setDropDownFont(Font)
Sets the drop-down list font.
 o setEditable(boolean)
Conditionally sets the ComboBox to be user-editable.
 o setEditFieldFont(Font)
Sets the edit field font.
 o setFont(Font)
Sets this component's text font.
 o setListItems(String[])
Adds the string array to the list.
 o setSearchable(boolean)
Conditionally sets the ComboBox to be searchable.
 o setShowHorizontalScroll(boolean)
Sets whether or not the horizontal scrollbar should be made visible when necessary or should never be made visible.
 o setShowVerticalScroll(boolean)
Sets whether or not the vertical scrollbar should be made visible when necessary or should never be made visible.
 o unDropLastDropped()
"Un-drop" the last ComboBox that was dropped down.

Variables

 o EVT_IMAGE_SELECT
  public final static int EVT_IMAGE_SELECT
The ID of the event posted when the image part of a drop-down list item is selected.

Constructors

 o ComboBox
  public ComboBox()
Constructs a new default ComboBox. The ComboBox is not editable and not searchable by default.

 o ComboBox
  public ComboBox(boolean editable,
                  boolean searchable)
Constructs a new editable and/or searchable ComboBox.

Parameters:
editable - true = editable, false = non-editable
searchable - true = searchable, false = non-searchable

Methods

 o setEditable
  public void setEditable(boolean editable)
Conditionally sets the ComboBox to be user-editable.

Parameters:
editable - true = editable, false = non-editable
See Also:
getEditable
 o getEditable
  public boolean getEditable()
Gets whether the ComboBox is user-editable.

Returns:
true if it is user-editable, false otherwise
See Also:
setEditable
 o setSearchable
  public void setSearchable(boolean searchable)
Conditionally sets the ComboBox to be searchable. A searchable ComboBox allows the user to enter text into the text field as long as it matches one of the existing list items. This allows the user to select from a non-editable list by typing instead of dropping-down the list and selecting with the mouse.

Parameters:
searchable - true = searchable, false = non-searchable
See Also:
getSearchable
 o getSearchable
  public boolean getSearchable()
Returns the current ComboBox "searchable" status. A searchable ComboBox allows the user to enter text into the text field as long as it matches one of the existing list items. This allows the user to select from a non-editable list by typing instead of dropping-down the list and selecting with the mouse.

See Also:
setSearchable
 o setCaseSensitive
  public void setCaseSensitive(boolean bCaseSensitive)
Conditionally sets the ComboBox to be case-sensitive during searches.

Parameters:
bCaseSensitive - true = case-sensitive, false = case-insensitive
See Also:
getCaseSensitive
 o getCaseSensitive
  public boolean getCaseSensitive()
Returns the current ComboBox case-sensitive search status.

See Also:
setSearchable
 o setShowHorizontalScroll
  public void setShowHorizontalScroll(boolean cond)
Sets whether or not the horizontal scrollbar should be made visible when necessary or should never be made visible.

Parameters:
cond - true = show when necessary, false = never show
See Also:
getShowHorizontalScroll
 o getShowHorizontalScroll
  public boolean getShowHorizontalScroll()
Gets the current horizontal scrollbar display option.

Returns:
true if the horizontal scrollbar should be displayed when necessary, false if it should never be shown
See Also:
setShowHorizontalScroll
 o setShowVerticalScroll
  public void setShowVerticalScroll(boolean cond)
Sets whether or not the vertical scrollbar should be made visible when necessary or should never be made visible.

Parameters:
cond - true = show when necessary, false = never show
See Also:
getShowVerticalScroll
 o getShowVerticalScroll
  public boolean getShowVerticalScroll()
Gets the current vertical scrollbar display option.

Returns:
true if the vertical scrollbar should be displayed when necessary, false if it should never be shown
See Also:
setShowVerticalScroll
 o setComboBoxFont
  public synchronized void setComboBoxFont(Font f)
Sets the edit field and drop-down list font.

Parameters:
f - the new edit field and drop-down list font
See Also:
getComboBoxFont
 o getComboBoxFont
  public synchronized Font getComboBoxFont()
Returns the current edit field and drop-down list font.

See Also:
setComboBoxFont
 o setEditFieldFont
  public synchronized void setEditFieldFont(Font f)
Sets the edit field font.

Parameters:
f - the new edit field font
See Also:
getEditFieldFont
 o getEditFieldFont
  public synchronized Font getEditFieldFont()
Returns the current edit field font.

See Also:
setEditFieldFont
 o setDropDownFont
  public synchronized void setDropDownFont(Font f)
Sets the drop-down list font.

Parameters:
f - the new drop-down list font
See Also:
getDropDownFont
 o getDropDownFont
  public synchronized Font getDropDownFont()
Returns the current drop-down list font.

See Also:
setDropDownFont
 o handleEvent
  public boolean handleEvent(Event evt)
Processes events for this component. This is a standard Java AWT method which gets called by the AWT to handle this component's events. The default handler for components dispatches to one of the following methods as needed: action(), gotFocus(), lostFocus(), keyDown(), keyUp(), mouseEnter(), mouseExit(), mouseMove(), mouseDrag(), mouseDown(), or mouseUp().

Parameters:
evt - the event to handle
Returns:
true if the event was handled and no further action is needed, false to pass the event to this component's parent
Overrides:
handleEvent in class Component
See Also:
action, gotFocus, lostFocus, keyDown, keyUp, mouseEnter, mouseExit, mouseMove, mouseDrag, mouseDown, mouseUp
 o addFirstTopDown
  public static boolean addFirstTopDown()
Determines whether the ComboBox should be the first component added to its container, or the last. This varies from system to system depending on the native user interface. If this method returns true, add the ComboBox before adding other components. If it returns false, add other components before adding the ComboBox. If the ComboBox is added in the wrong order, the drop-down list box will be drawn under the other components instead of on top of them.

Returns:
if true add the ComboBox to its container before other components, otherwise add after all other components
See Also:
addLastBottomUp
 o addLastBottomUp
  public static boolean addLastBottomUp()
Determines whether the ComboBox should be the last component added to its container, or the first. This varies from system to system depending on the native user interface. If this method returns true, add the ComboBox after adding other components. If it returns false, add other components after adding the ComboBox. If the ComboBox is added in the wrong order, the drop-down list box will be drawn under the other components instead of on top of them.

Returns:
if true add the ComboBox to its container after other components, otherwise add before all other components
See Also:
addFirstTopDown
 o needsPlatformHelp
  public static boolean needsPlatformHelp()
Use this method to set a flag for use in your handleEvent to determine if the ComboBox needs help in "un-dropping". This will improve useability under platforms which do not provide proper focus events. For best performance assign a variable in your class once to avoid repeated function calls to this method, like this:
   boolean bNeedsPlatformHelp = ComboBox.needsPlatformHelp();
   public boolean handleEvent(Event evt)
   {
       switch (evt.id)
       {
           case Event.MOUSE_UP:
               // do it on mouse up, which indicates a full click somewhere other than
               // the ComboBox that could be currently dropped down.
               if (bNeedsPlatformHelp)
                   ComboBox.unDropLastDropped();
               break; // or other MOUSE_UP processing as necessary
           ...
       }
       ...
   }
 

See Also:
unDropLastDropped
 o unDropLastDropped
  public static void unDropLastDropped()
"Un-drop" the last ComboBox that was dropped down.

See Also:
needsPlatformHelp
 o clear
  public void clear()
Clears all items from the drop-down list.

 o addItem
  public synchronized void addItem(String item)
Adds the specified item to the end of the drop-down list and enables the item.

Parameters:
item - the item to be added
See Also:
addItem, addItem, addItem, setListItems
 o addItem
  public synchronized void addItem(String item,
                                   boolean bEnabled)
Adds the specified item to the end of the drop-down list and conditionally enables it.

Parameters:
item - the item to be added
bEnabled - true = enable the item, false = disable it
See Also:
addItem, addItem, addItem, setListItems
 o addItem
  public synchronized void addItem(Image image,
                                   String item)
Adds the specified item with an image to the end of the drop-down list and enables it.

Parameters:
image - the image to display on the item line
item - the item to be added
See Also:
addItem, addItem, addItem, setListItems
 o addItem
  public synchronized void addItem(Image image,
                                   String item,
                                   boolean bEnabled)
Adds the specified item with an image to the end of drop-down the list and conditionally enables it.

Parameters:
image - the image to display on the item line
item - the item to be added
bEnabled - true = enable the item, false = disable it
See Also:
addItem, addItem, addItem, setListItems
 o setListItems
  public void setListItems(String items[])
Adds the string array to the list.

Parameters:
items - items to add to the list
See Also:
getListItems, addItem, addItem, addItem, addItem
 o getListItems
  public String[] getListItems()
Returns the current list as an array.

See Also:
setListItems
 o countItems
  public int countItems()
Returns the total number of items in the drop-down list.

 o getItem
  public String getItem(int index)
Returns the drop-down list item at the specified zero-relative index.

 o changeImage
  public void changeImage(int index,
                          Image image)
Changes the image associated with a drop-down list item.

Parameters:
index - the zero-relative index of the drop-down list item
image - the image to associate with the drop-down list item
 o changeText
  public void changeText(int index,
                         String text)
Changes the text associated with a drop-down list item.

Parameters:
index - the zero-relative index of the drop-down list item
text - the text to associate with the drop-down list item
 o enable
  public void enable(int index)
Enables a drop-down list item at a given zero-relative index.

Parameters:
index - the zero-relative index of the drop-down list item
See Also:
disable
 o disable
  public void disable(int index)
Disables a drop-down list item at a given zero-relative index.

Parameters:
index - the zero-relative index of the drop-down list item
See Also:
enable
 o enable
  public void enable(int index,
                     boolean cond)
Conditionally enables a drop-down list item at a given zero-relative index.

Parameters:
index - the zero-relative index of the drop-down list item
cond - true = enable the item, false = disable it
See Also:
disable
 o delItem
  public synchronized void delItem(int position)
Deletes an item from the drop-down list.

Parameters:
position - the zero-relative index of the item
See Also:
delItems, addItem, addItem, addItem, addItem, setListItems
 o delItems
  public synchronized void delItems(int start,
                                    int end)
Deletes multiple items from the drop-down list. (Note: the end position must be greater than or equal to the start position.)

Parameters:
start - the starting zero-relative index of the items
end - the ending zero-relative index of the items
See Also:
delItem, addItem, addItem, addItem, addItem, setListItems
 o delSelectedItem
  public synchronized void delSelectedItem()
Deletes the currently selected item from the list.

See Also:
addItem, addItem, addItem, addItem, setListItems
 o getText
  public String getText()
Returns the text in the edit field portion of the ComboBox, unless the ComboBox is not editable.

Returns:
the edit field text if editable, or null if this ComboBox is not editable
See Also:
getSelectedItem
 o getSelectedItem
  public String getSelectedItem()
Returns the selected item on the drop-down list.

Returns:
the text of the selected item, or null if no item is selected
See Also:
getText, getSelectedIndex
 o getSelectedIndex
  public int getSelectedIndex()
Gets the zero-relative index of the currently selected item in the drop-down list.

Returns:
the zero-relative index of the current selection, or -1 if no item is selected
See Also:
getSelectedItem
 o select
  public synchronized void select(int index)
Selects the drop-down list item with the specified zero-relative index.

Parameters:
index - the zero-relative index of the drop-down list item to select
See Also:
deselect
 o select
  public void select(String str)
Selects the first drop-down item in the list which has exactly matching text.

Parameters:
str - the string to match
See Also:
deselect
 o deselect
  public synchronized void deselect(int index)
Deselects the drop-down list item at the specified zero-relative index.

Parameters:
index - the zero-relative index of the drop-down item to deselect
See Also:
deselect
 o isSelected
  public synchronized boolean isSelected(int index)
Returns the selection state of the list item at the given zero-relative index.

Parameters:
index - the zero-relative index of the drop-down list item to be checked
Returns:
true if the drop-down list item at the specified index has been selected; false otherwise
See Also:
select
 o setFont
  public synchronized void setFont(Font f)
Sets this component's text font. This is a standard Java AWT method which gets called to change the font used for drawing text in this component. In this case the text is in the edit field and the drop-down list items.

Parameters:
f - the new font to use for drawing text
Overrides:
setFont in class Component
See Also:
getFont
 o dropList
  public void dropList(boolean bDown)
Handles dropping and "un-dropping" the ComboBox list.

Parameters:
bDown - true to drop the list, false to "un-drop" the list.
 o reshape
  public synchronized void reshape(int x,
                                   int y,
                                   int width,
                                   int height)
Moves and/or resizes this component. This is a standard Java AWT method which gets called to move and/or resize this component. Components that are in containers with layout managers should not call this method, but rely on the layout manager instead.

Parameters:
x - horizontal position in the parent's coordinate space
y - vertical position in the parent's coordinate space
width - the new width
height - the new height
Overrides:
reshape in class Component
 o paint
  public void paint(Graphics g)
Paints this component using the given graphics context. This is a standard Java AWT method which typically gets called by the AWT to handle painting this component. It paints this component using the given graphics context. The graphics context clipping region is set to the bounding rectangle of this component and its <0,0> coordinate is this component's top-left corner.

Parameters:
g - the graphics context used for painting
Overrides:
paint in class Container
See Also:
repaint, update
 o preferredSize
  public Dimension preferredSize()
Returns the recommended dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the recommended size of this component. Considerations include the number of rows in the list.

Overrides:
preferredSize in class Container
See Also:
minimumSize
 o minimumSize
  public Dimension minimumSize()
Returns the minimum dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the minimum size of this component.

Overrides:
minimumSize in class Container
See Also:
preferredSize

All Packages  Class Hierarchy  This Package  Previous  Next  Index