public class G9ComboBox extends JComboBox implements G9FieldValue, G9ValueState
| Modifier and Type | Class and Description |
|---|---|
class |
G9ComboBox.SelectionManager
The class for managing selections by key stroke on a non-searchable combo
box.
|
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManagerJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected EventListenerList |
vcListeners
List of value changed listeners
|
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminderlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
G9ComboBox()
Creates a
JComboBox with a default data model. |
| Modifier and Type | Method and Description |
|---|---|
void |
addAllItems(Collection<? extends Object> items)
Adds a collection of items to the combo box.
|
void |
addG9SelectionListener(G9SelectionListener listener)
Adds a g9 selected listener to this component.
|
void |
addItem(Collection<? extends Object> items)
Adds a collection of items to the item list.
|
void |
addItem(Object anObject) |
void |
addItem(String enumTitle,
Class<?> enumType)
Adds an enumeration to this combo.
|
void |
addValueChangedListener(G9ValueChangedListener listener)
Adds a change listener to this component.
|
void |
display(Object anObject)
Sets the specified object as the selected object.
|
void |
editingAboutToBegin()
Internal use! Will not be implemented until editable listblock is
supported.
|
void |
fireG9SelectedEvent(int oldSelection,
int newSelection)
Fires a g9 selection event
|
protected void |
fireG9ValueChangedEvent(int id,
Object oldValue,
Object newValue)
Fires a g9 value changed event.
|
String |
format()
Formats the selected value into the approriate string representation.
|
String |
format(Object anObject)
Returns the String value used when displaying the specified object
|
protected Object |
getDisplayValue(Object anObject)
Gets the value used for displaying
anObject. |
Object |
getInitialValue()
Returns the initial displayed value.
|
int |
getNumberOfPossibleHits(String searchString,
boolean caseSensitive)
Returns the number of possible search hits using the specified search
string.
|
Object |
getSelectedItem() |
String |
getSelectedItemAsString()
Returns the string representation of the selected item (viz.
|
Object |
getValue()
Gets the selected value object.
|
boolean |
isCaseSenstitiveSearch()
Returns the value used when determening if searching is case sensitive.
|
boolean |
isChanged()
Checks if the currently displayed value is the same as the initial
value.
|
boolean |
isCustomEditable()
Returns the isCustomEditable property
|
boolean |
isDontFire()
Internal use, returns the dontFire flag.
|
boolean |
isSearchable()
Returns the isSearchable property
|
boolean |
isSearchHit(String searchString)
Returns true if an item (viz.
|
Object |
parse(String formattedString)
Returns a value object.
|
void |
reset()
Resets the current displayed value and the state of the combo box.
It the combo list contains any elements, the first element is chosen. |
void |
resetState()
Forces the currently displayed value to be considered the old value.
|
void |
setCaseSensitiveSearch(boolean aFlag)
Sets whether searching is case sensitive or not (only applies to
searchable combos).
|
void |
setEditable(boolean aFlag)
Sets the combo to be editable.
|
void |
setHorizontalAlignment(int alignment)
Sets the horizontal alignment.
|
void |
setInitialValue(Object value)
Sets the initial value to be the specified value.
|
void |
setInputJustification(int justification)
Sets the input justification
|
void |
setOutputJustification(int outputJustification)
Sets the output justification.
|
void |
setSearchable(boolean searchable)
Sets this combo as searchable.
|
void |
setSelectAllOnFocus(boolean selectAllOnFocus)
Internal use.
|
void |
setSelectedItem(Object anObject) |
void |
setSelectedItemG9(Object value)
Deprecated.
This method is now obsolete and should not be used. Use
setSelectedItem(Object) instead. |
void |
setSorted(boolean isSorted)
Sets the isSorted property.
|
void |
setUsedAsListblockEditor(DefaultCellEditor tx)
Internal use! Will not be implemented until editable listblock is
supported.
|
void |
setValue(Object value)
Selects a value, this is the same as invoking display(value).
|
actionPerformed, actionPropertyChanged, addActionListener, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyBinding, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setUI, showPopup, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleprotected EventListenerList vcListeners
public G9ComboBox()
JComboBox with a default data model.
The default data model is an empty list of objects.
Use addItem to add items. By default the first item
in the data model becomes selected.DefaultComboBoxModelprotected void fireG9ValueChangedEvent(int id,
Object oldValue,
Object newValue)
id - the type of eventoldValue - the old valuenewValue - the new valuepublic String format(Object anObject)
anObject - the object holding the valuepublic String format()
format in interface G9FieldValuepublic Object getValue()
getValue in interface G9FieldValuepublic Object parse(String formattedString)
G9FieldValueparse in interface G9FieldValueformattedString - (missing javadoc)public void setValue(Object value)
setValue in interface G9FieldValuevalue - the value to setdisplay(Object)public void addValueChangedListener(G9ValueChangedListener listener)
G9ValueStateaddValueChangedListener in interface G9ValueStatelistener - the listener to addpublic void display(Object anObject)
setSelectedItem(Object).display in interface G9ValueStateanObject - the object to select.public Object getInitialValue()
G9ValueStategetInitialValue in interface G9ValueStatepublic boolean isChanged()
G9ValueStateisChanged in interface G9ValueStatetrue if the displayed value differs from the
initial value.public Object getSelectedItem()
getSelectedItem in class JComboBoxpublic void reset()
public void resetState()
G9ValueStateresetState in interface G9ValueStatepublic void setInitialValue(Object value)
If the specified initial value is "null", and this the combo is not editable, and the list does not contain "null", the first item is choosen as the initial value. If the specified value is a String, the list is searched for an item that matches the string. If found, that item is used.
setInitialValue in interface G9ValueStatevalue - the (new) initial value.public void setSelectAllOnFocus(boolean selectAllOnFocus)
Sets the select all on focus property.
selectAllOnFocus - (missing javadoc)public String getSelectedItemAsString()
@Deprecated public void setSelectedItemG9(Object value)
setSelectedItem(Object) instead.value - the value to selectJComboBox.setSelectedItem(Object)public void addItem(Collection<? extends Object> items)
JComboBox uses a mutable data model.
Warning: Focus and keyboard navigation problems may
arise if you add duplicate String objects. A workaround is to add new
objects instead of String objects and make sure that the toString()
method is defined, see JComboBox.addItem(Object)
items - the Collection of objects to add to the listMutableComboBoxModelpublic void addAllItems(Collection<? extends Object> items)
addItem(Collection).items - a collection of items.addItem(Collection)public void addItem(String enumTitle, Class<?> enumType)
enumTitle - the title of the enum (current value)enumType - the type of enumpublic void setInputJustification(int justification)
justification - value specifying the input justification. See
JTextField.setHorizontalAlignment(int) for a list of
valid parameters.public void setOutputJustification(int outputJustification)
outputJustification - value specifying the output justification. See
JTextField.setHorizontalAlignment(int) for a list of
valid parameters.public void setHorizontalAlignment(int alignment)
alignment - the alignment, see
JTextField.setHorizontalAlignment(int) for a list of
valid parameters.public void setSorted(boolean isSorted)
isSorted - (missing javadoc)protected Object getDisplayValue(Object anObject)
anObject.anObject - the object to get the display value ofpublic void setEditable(boolean aFlag)
setEditable in class JComboBoxaFlag - a boolean value where true indicates that this combo is
editable.public int getNumberOfPossibleHits(String searchString, boolean caseSensitive)
searchString - the string used for searching.caseSensitive - a boolean value where false indicates that case is
not significant.public boolean isSearchHit(String searchString)
searchString - the string used for searchingtrue if an exact match is found.public void setCaseSensitiveSearch(boolean aFlag)
aFlag - a boolean value where true indicates that searching is case
sensitive.public boolean isCaseSenstitiveSearch()
setCaseSensitiveSearch(boolean)public void setSearchable(boolean searchable)
isEditable on a
searchable combo results in true. In order to make it true
editable, one must invoke the setEditable method.searchable - a boolean value, true indicating that this combo is
searchable.public void setSelectedItem(Object anObject)
setSelectedItem in class JComboBoxpublic boolean isSearchable()
true if this combo is searchable.setSearchable(boolean)public boolean isCustomEditable()
true if this combo is editablesetEditable(boolean)public void addG9SelectionListener(G9SelectionListener listener)
listener - the listenerpublic void fireG9SelectedEvent(int oldSelection,
int newSelection)
oldSelection - the index of the old selectionnewSelection - the index of the new selectionpublic void setUsedAsListblockEditor(DefaultCellEditor tx)
tx - the cell editor.public void editingAboutToBegin()
public boolean isDontFire()
Copyright © 2006–2018 Esito AS. All rights reserved.