Compiere 3.1

org.compiere.swing
Class CComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JComboBox
                  extended by org.compiere.swing.CComboBox
All Implemented Interfaces:
ActionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, ListDataListener, CEditor
Direct Known Subclasses:
CPrinter, VComboBox, VPrinter

public class CComboBox
extends JComboBox
implements CEditor

Compiere Colored Combo Box. By default, auto-reduction of choices is on and is not case sensitive. Editing the number of choices will always be passed through directly to the unfiltered ComboBoxModel.

Version:
$Id: CComboBox.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $
Author:
Jorg Janke
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComboBox
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String AUTO_REDUCIBLE_PROPERTY
          Property key for auto-reduction.
static String CASE_SENSITIVE_PROPERTY
          Property key for case sensitive auto-reduction.
static int FIELD_HIGHT
          Size
 
Fields inherited from class javax.swing.JComboBox
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CComboBox()
          Creates a JComboBox with a default data model.
CComboBox(ComboBoxModel aModel)
          Creates a JComboBox that takes it's items from an existing ComboBoxModel.
CComboBox(Object[] items)
          Creates a JComboBox that contains the elements in the specified array.
CComboBox(Object[] items, String key)
          Creates a JComboBox that contains the elements in the specified array.
CComboBox(Vector<?> items)
          Creates a JComboBox that contains the elements in the specified Vector.
 
Method Summary
 void addMouseListener(MouseListener ml)
          Add Mouse Listener - 1-4-0 Bug.
 boolean displayPopup()
          Display Popup.
 ComboBoxModel getCompleteComboBoxModel()
          Retrieves the complete and unfiltered ComboBoxModel.
 String getDisplay()
          Return Display Value
 Object getValue()
          Return Editor value
 boolean isAutoReducible()
          Is the combo box auto-reducible?
 boolean isCaseSensitive()
          Is the auto-reduction case sensitive?
 boolean isMandatory()
          Is Field mandatory
protected  boolean isMatchingFilter(Object element)
          Called only when auto-reducing.
 boolean isReadWrite()
          Is it possible to edit
static void main(String[] args)
          Test
 void removeAllItems()
           
 void removeMouseListener(MouseListener ml)
          Remove Mouse Listener.
 void setActionCommand(String actionCommand)
          Set Action Command
 void setAutoReducible(boolean autoreducible)
          Set whether the combo box is auto-reducible.
 void setBackground(boolean error)
          Set Background based on editable / mandatory / error
 void setBackground(Color bg)
          Set Background
 void setCaseSensitive(boolean caseSensitive)
          Set whether auto-reduction is case sensitive.
 void setIcon(Icon defaultIcon)
          Set Icon of arrow button to icon
 void setMandatory(boolean mandatory)
          Set Editor Mandatory
 void setModel(ComboBoxModel aModel)
           
 void setOpaqueAll(boolean isOpaque)
          Set All Opaque (incl.
 void setReadWrite(boolean rw)
          Enable Editor
 void setUI(ComboBoxUI ui)
          Set UI and re-set Icon for arrow button
 void setValue(Object value)
          Set Editor to value
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, actionPropertyChanged, addActionListener, addItem, 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, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setSelectedItem, showPopup, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, 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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, 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, hide, 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, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.compiere.swing.CEditor
setVisible
 

Field Detail

FIELD_HIGHT

public static int FIELD_HIGHT
Size


AUTO_REDUCIBLE_PROPERTY

public static final String AUTO_REDUCIBLE_PROPERTY
Property key for auto-reduction.

See Also:
Constant Field Values

CASE_SENSITIVE_PROPERTY

public static final String CASE_SENSITIVE_PROPERTY
Property key for case sensitive auto-reduction.

See Also:
Constant Field Values
Constructor Detail

CComboBox

public CComboBox(ComboBoxModel aModel)
Creates a JComboBox that takes it's items from an existing ComboBoxModel. Since the ComboBoxModel is provided, a combo box created using this constructor does not create a default combo box model and may impact how the insert, remove and add methods behave.

Parameters:
aModel - the ComboBoxModel that provides the displayed list of items
See Also:
DefaultComboBoxModel

CComboBox

public CComboBox(Object[] items)
Creates a JComboBox that contains the elements in the specified array. By default the first item in the array (and therefore the data model) becomes selected.

Parameters:
items - an array of objects to insert into the combo box
See Also:
DefaultComboBoxModel

CComboBox

public CComboBox(Object[] items,
                 String key)
Creates a JComboBox that contains the elements in the specified array. By default the first item in the array (and therefore the data model) becomes selected.

Parameters:
items - an array of objects to insert into the combo box
key - set selected if exists
See Also:
DefaultComboBoxModel

CComboBox

public CComboBox(Vector<?> items)
Creates a JComboBox that contains the elements in the specified Vector. By default the first item in the vector and therefore the data model) becomes selected.

Parameters:
items - an array of vectors to insert into the combo box
See Also:
DefaultComboBoxModel

CComboBox

public CComboBox()
Creates a 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.

See Also:
DefaultComboBoxModel
Method Detail

setIcon

public void setIcon(Icon defaultIcon)
Set Icon of arrow button to icon

Parameters:
defaultIcon - Icon to be displayed

getCompleteComboBoxModel

public ComboBoxModel getCompleteComboBoxModel()
Retrieves the complete and unfiltered ComboBoxModel. Use this when complete and unfiltered access to all the combo box choices is necessary.

Returns:

setModel

public void setModel(ComboBoxModel aModel)
Overrides:
setModel in class JComboBox
See Also:
JComboBox.setModel(javax.swing.ComboBoxModel)

setUI

public void setUI(ComboBoxUI ui)
Set UI and re-set Icon for arrow button

Overrides:
setUI in class JComboBox
Parameters:
ui -

displayPopup

public boolean displayPopup()
Display Popup. Called from CompiereComboPopup and allows to implement alternative actions than showing the popup

Returns:
if true, the popup should be displayed

setMandatory

public void setMandatory(boolean mandatory)
Set Editor Mandatory

Specified by:
setMandatory in interface CEditor
Parameters:
mandatory - true, if you have to enter data

isMandatory

public boolean isMandatory()
Is Field mandatory

Specified by:
isMandatory in interface CEditor
Returns:
true, if mandatory

setReadWrite

public void setReadWrite(boolean rw)
Enable Editor

Specified by:
setReadWrite in interface CEditor
Parameters:
rw - true, if you can enter/select data

isReadWrite

public boolean isReadWrite()
Is it possible to edit

Specified by:
isReadWrite in interface CEditor
Returns:
true, if editable

setBackground

public void setBackground(boolean error)
Set Background based on editable / mandatory / error

Specified by:
setBackground in interface CEditor
Parameters:
error - if true, set background to error color, otherwise mandatory/editable

setBackground

public void setBackground(Color bg)
Set Background

Overrides:
setBackground in class JComponent
Parameters:
bg -

setOpaqueAll

public void setOpaqueAll(boolean isOpaque)
Set All Opaque (incl. Text)

Parameters:
isOpaque - opaque

setValue

public void setValue(Object value)
Set Editor to value

Specified by:
setValue in interface CEditor
Parameters:
value - value of the editor

getValue

public Object getValue()
Return Editor value

Specified by:
getValue in interface CEditor
Returns:
current value

getDisplay

public String getDisplay()
Return Display Value

Specified by:
getDisplay in interface CEditor
Returns:
displayed String value

addMouseListener

public void addMouseListener(MouseListener ml)
Add Mouse Listener - 1-4-0 Bug. Bug in 1.4.0 Metal: arrowButton gets Mouse Events, so add the JComboBox MouseListeners to the arrowButton - No context menu if right-click

Overrides:
addMouseListener in class Component
Parameters:
ml -
See Also:
CompiereComboBoxUI.installUI(JComponent)

removeMouseListener

public void removeMouseListener(MouseListener ml)
Remove Mouse Listener.

Overrides:
removeMouseListener in class Component
Parameters:
ml -

setActionCommand

public void setActionCommand(String actionCommand)
Set Action Command

Overrides:
setActionCommand in class JComboBox
Parameters:
actionCommand - command

isMatchingFilter

protected boolean isMatchingFilter(Object element)
Called only when auto-reducing. By default, does a case insensitive string search for a match in the string representation of the given element.

Parameters:
element - an element in the combo box model
Returns:
true if the choice is to be displayed in the popup menu

isAutoReducible

public boolean isAutoReducible()
Is the combo box auto-reducible?

Returns:
true if isAutoReducible()

setAutoReducible

public void setAutoReducible(boolean autoreducible)
Set whether the combo box is auto-reducible. The combo box must also be editable for auto-reduction to fully functional. Auto-reduction of data will preclude the ability for users to enter in their own choices.

Parameters:
autoreducible - true will activate auto-reduction of choices when user enters text

isCaseSensitive

public boolean isCaseSensitive()
Is the auto-reduction case sensitive?

Returns:
true if case sensitive

removeAllItems

public void removeAllItems()
Overrides:
removeAllItems in class JComboBox

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Set whether auto-reduction is case sensitive.

Parameters:
caseSensitive - true will make auto-reduction is case sensitive

main

public static void main(String[] args)
Test

Parameters:
args -

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.