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