|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JComboBox com.jidesoft.combobox.ExComboBox
public abstract class ExComboBox
This class provides an extended version of JComboBox. It can
Nested Class Summary | |
---|---|
protected class |
ExComboBox.LazyDelegateAction
|
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 |
CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED
|
static String |
CLIENT_PROPERTY_POPUP_PANEL
|
static String |
CLIENT_PROPERTY_TABLE_CELL_EDITOR
|
static String |
CLIENT_PROPERTY_TABLE_CELL_RENDERER
|
static int |
COMMIT
Constant identifying that when focus is lost, commitEdit should be invoked. |
static int |
COMMIT_OR_RESET
Constant identifying that when focus is lost, commitEdit should be invoked. |
static int |
COMMIT_OR_REVERT
Constant identifying that when focus is lost, commitEdit should be invoked. |
static int |
DIALOG
If the ExComboBox type is DIALOG, the popup panel will be shown as dialog. |
static int |
DOWN_KEY_BEHAVIOR_SELECT_NEXT
Constant identifying that pressing down key on a non-editable ExComboBox will select next possible value like plain JComboBox does by default. |
static int |
DOWN_KEY_BEHAVIOR_SHOW_POPUP
Constant identifying that pressing down key on a non-editable ExComboBox will show popup. |
static int |
DROPDOWN
If the ExComboBox type is DROPDOWN, the popup panel will be shown as dropdown. |
static int |
PERSIST
Constant identifying that when focus is lost, the edited value should be left. |
static String |
PROPERTY_BUTTON_VISIBLE
|
static String |
PROPERTY_SELECTED_ITEM
|
static int |
RESET
Constant identifying that when focus is lost, the editing value will be reset to null. |
static int |
REVERT
Constant identifying that when focus is lost, the editing value should be reverted to current value set on the ExComboBox . |
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 | |
---|---|
ExComboBox()
|
|
ExComboBox(ComboBoxModel aModel)
|
|
ExComboBox(int type)
Creates a new ExComboBox with default context. |
|
ExComboBox(int type,
ConverterContext context)
Creates a new ExComboBox . |
|
ExComboBox(Object[] items)
|
|
ExComboBox(Vector<?> items)
|
Method Summary | |
---|---|
protected boolean |
comboBoxSelected()
Check if this combo box is a selected cell inside a JTable. |
boolean |
commitEdit()
Commits the editing change to the ExComboBox. |
void |
commitEditWithFocusLostBehavior(boolean commit)
Conditionally commit the edit considering the focusLostBehavior. |
String |
convertElementToString(Object value)
|
String |
convertElementToString(Object value,
Class clazz)
|
Object |
convertStringToElement(String text)
|
Object |
convertStringToElement(String text,
Class clazz)
|
AbstractButton |
createButtonComponent()
Subclass should override this method to create the actual button component. |
abstract PopupPanel |
createPopupComponent()
Subclass should implement this method to create the actual popup component. |
void |
customizeDialog(JDialog dialog)
Customizes the dialog. |
void |
customizeDialogLocation(JDialog dialog)
Customizes the dialog location. |
void |
customizePopup(JidePopup popup,
PopupPanel panel)
Customizes the popup and the popup panel before actually showing them. |
void |
customizeRendererComponent(Component rendererComponent,
Object value,
int index,
boolean selected,
boolean cellHasFocus)
|
void |
delegateKeyStrokes()
Delegates key strokes to popup panel. |
protected boolean |
equals(Object object1,
Object object2)
Check if object1 is equal to object2. |
void |
fireActionEvent()
|
protected void |
fireItemStateChanged(ItemEvent e)
|
String |
getActualUIClassID()
|
ObjectConverter |
getConverter()
|
ConverterContext |
getConverterContext()
Gets the converter context. |
protected AbstractAction |
getDefaultCancelAction()
Gets the default Cancel action for the Cancel button on the drop down panel, if needed. |
protected AbstractAction |
getDefaultOKAction()
Gets the default OK action for the OK button on the drop down panel, if needed. |
List<KeyStroke> |
getDelegateKeyStrokes()
Gets the list of KeyStrokes that will be delegated to the popup panel. |
protected JComponent |
getDelegateTarget(PopupPanel panel)
|
Action |
getDialogCancelAction()
Gets the cancel button action for the dialog type ComboBox. |
Action |
getDialogOKAction()
Gets the OK button action for the dialog type ComboBox. |
int |
getDownKeyBehavior()
Gets the behavior when pressing down key on a non-editable ExComboBox. |
int |
getFocusLostBehavior()
Returns the behavior when focus is lost. |
int |
getPopupCancelBehavior()
Returns the behavior when the popup drop down is canceled. |
int |
getPopupLocation()
Gets the popup location. |
int |
getPopupType()
Gets the popup type. |
Object |
getSelectedItem()
Returns the current selected item. |
Class<?> |
getType()
Gets the class of the value. |
String |
getUIComboBoxEditorClassID()
Returns a string that specifies the name of the ComboBoxEditor class that should be created for the ExComboBox. |
String |
getUIComboBoxPopupClassID()
Returns a string that specifies the name of the ComboBoxPopup class that should be created for the ExComboBox. |
String |
getUIComboBoxRendererClassID()
Returns a string that specifies the name of the cell renderer class that should be created for the ExComboBox. |
protected void |
initComboBox()
|
protected void |
installColorFontAndBorder(JTable table,
boolean isSelected,
boolean hasFocus,
int row,
int column)
|
boolean |
isButtonOnly()
Checks if only the button is visible. |
boolean |
isButtonVisible()
Checks if the button is visible. |
boolean |
isEmptyStringNull()
Gets the flag indicating if empty string allowed as a non-null value. |
boolean |
isKeepPopupSize()
Checks if the popup size is kept when the popup is shown again. |
boolean |
isPopupVolatile()
Checks if the popup is volatile. |
boolean |
isReallyFocusLost(FocusEvent e)
|
boolean |
isRetrievingValueFromPopup()
|
boolean |
isStretchToFit()
Checks if the popup panel should be stretched to be the same width as the ComboBox. |
boolean |
isStretchToFitSet()
|
protected boolean |
isUpdateFromPopupOnFly()
This is a flag used internally. |
protected void |
notifyUser()
Calls PortingUtils.notifyUser() to notify the user an error occurred when committing the edit. |
void |
popupMenuCanceled(PopupMenuEvent e)
|
boolean |
processKeyBinding(KeyStroke keyStroke,
KeyEvent keyEvent,
int i,
boolean b)
|
void |
propertyChange(PropertyChangeEvent evt)
|
void |
resetEdit()
Cancels the editing change and resets to null. |
void |
revertEdit()
Cancels the editing change and reverts to the previous valid. |
boolean |
selectWithKeyChar(char keyChar)
|
void |
setButtonOnly(boolean buttonOnly)
Sets the visibility of the editor and only makes the button visible. |
void |
setButtonVisible(boolean buttonVisible)
Sets the visibility of the button. |
void |
setConverter(ObjectConverter converter)
|
void |
setConverterContext(ConverterContext converterContext)
Sets the converter context. |
void |
setDownKeyBehavior(int downKeyBehavior)
Sets the behavior when pressing down key on a non-editable ExComboBox. |
void |
setEditable(boolean aFlag)
|
void |
setEmptyStringNull(boolean emptyStringNull)
Sets the flag indicating if empty string allowed as a non-null value. |
void |
setFocusLostBehavior(int behavior)
Sets the behavior when focus is lost. |
void |
setKeepPopupSize(boolean keepPopupSize)
Sets the flag if the popup size should be kept. |
void |
setModel(ComboBoxModel aModel)
|
void |
setPopupCancelBehavior(int behavior)
Sets the behavior when the popup drop down is canceled. |
void |
setPopupLocation(int popupLocation)
|
void |
setPopupType(int popupType)
Sets the popup type. |
void |
setPopupVolatile(boolean popupVolatile)
Sets the volatile attribute of popup. |
void |
setSelectedItem(Object anObject)
Sets the selected item in the combo box display area to the object in the argument. |
void |
setSelectedItem(Object anObject,
boolean fireEvent)
Same as setSelectedItem(Object) except you can choose to fire the ItemEvent or not. |
void |
setStretchToFit(boolean stretchToFit)
Sets the flag if the popup panel should be stretched to be the same width as the ComboBox. |
void |
setType(Class<?> clazz)
Sets the class of the value. |
void |
undelegateKeyStrokes()
Undelegates keystrokes. |
void |
updateUI()
|
protected boolean |
validateValueForNonEditable(Object value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DROPDOWN
public static final int DIALOG
public static final int COMMIT
commitEdit
should be invoked. If in committing the new
value a ParseException
is thrown, the invalid value will remain.
setFocusLostBehavior(int)
,
Constant Field Valuespublic static final int COMMIT_OR_REVERT
commitEdit
should be invoked. If in committing the new
value a ParseException
is thrown, the value will be reverted.
setFocusLostBehavior(int)
,
Constant Field Valuespublic static final int REVERT
ExComboBox
.
setFocusLostBehavior(int)
,
Constant Field Valuespublic static final int PERSIST
setFocusLostBehavior(int)
,
Constant Field Valuespublic static final int COMMIT_OR_RESET
commitEdit
should be invoked. If in committing the new
value a ParseException
is thrown, the value will be reset to null.
setFocusLostBehavior(int)
,
Constant Field Valuespublic static final int DOWN_KEY_BEHAVIOR_SELECT_NEXT
public static final int DOWN_KEY_BEHAVIOR_SHOW_POPUP
public static final int RESET
setFocusLostBehavior(int)
,
Constant Field Valuespublic static final String PROPERTY_SELECTED_ITEM
public static final String PROPERTY_BUTTON_VISIBLE
public static final String CLIENT_PROPERTY_TABLE_CELL_RENDERER
public static final String CLIENT_PROPERTY_TABLE_CELL_EDITOR
public static final String CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED
public static final String CLIENT_PROPERTY_POPUP_PANEL
Constructor Detail |
---|
public ExComboBox()
public ExComboBox(Vector<?> items)
public ExComboBox(Object[] items)
public ExComboBox(ComboBoxModel aModel)
public ExComboBox(int type)
ExComboBox
with default context.
type
- DIALOG or DROPDOWNpublic ExComboBox(int type, ConverterContext context)
ExComboBox
.
type
- DIALOG or DROPDOWNcontext
- ConverterContextMethod Detail |
---|
protected void initComboBox()
public String getActualUIClassID()
public String getUIComboBoxPopupClassID()
public String getUIComboBoxEditorClassID()
public String getUIComboBoxRendererClassID()
public void updateUI()
updateUI
in class JComboBox
public abstract PopupPanel createPopupComponent()
public AbstractButton createButtonComponent()
public void setSelectedItem(Object anObject)
anObject
is
in the list, the display area shows anObject
selected.
If anObject
is not in the list and the combo box is not editable, it will not change the
current selection. For editable combo boxes, the selection will change to anObject
.
If this constitutes a change in the selected item, ItemListener
s added to the combo box will be
notified with one or two ItemEvent
s. If there is a current selected item, an ItemEvent
will be fired and the state change will be ItemEvent.DESELECTED
. If anObject
is in the
list and is not currently selected then an ItemEvent
will be fired and the state change will be
ItemEvent.SELECTED
.
ActionListener
s added to the combo box will be notified with an ActionEvent
when this
method is called.
setSelectedItem
in class JComboBox
anObject
- the list object to select; use null
to clear the selectionpublic void setSelectedItem(Object anObject, boolean fireEvent)
setSelectedItem(Object)
except you can choose to fire the ItemEvent or not.
anObject
- the new valuefireEvent
- true to fire event which is the same as setSelectedItem(Object)
. False if you don't
want to fire event.public void setEditable(boolean aFlag)
setEditable
in class JComboBox
protected void fireItemStateChanged(ItemEvent e)
fireItemStateChanged
in class JComboBox
protected boolean equals(Object object1, Object object2)
object1
- one of the two objectsobject2
- another one of the two objects
protected boolean validateValueForNonEditable(Object value)
public Object getSelectedItem()
addItem
,
insertItemAt
or the data constructors.
getSelectedItem
in class JComboBox
setSelectedItem(java.lang.Object)
protected JComponent getDelegateTarget(PopupPanel panel)
public void customizeRendererComponent(Component rendererComponent, Object value, int index, boolean selected, boolean cellHasFocus)
public int getDownKeyBehavior()
setDownKeyBehavior(int)
public void setDownKeyBehavior(int downKeyBehavior)
DOWN_KEY_BEHAVIOR_SELECT_NEXT
to be consistent with plain JComboBox. However,
for some ExComboBox's like DateExComboBox, TreeExComboBox, the behavior will always be to show popup.
downKeyBehavior
- the down key behaviorpublic void delegateKeyStrokes()
undelegateKeyStrokes()
will be called when popup panel is hidden.
Subclass can override it to delegate more. To delegate a KeyStroke, you can simply call DelegateAction.replaceAction(javax.swing.JComponent, int, javax.swing.KeyStroke,
com.jidesoft.swing.DelegateAction)
.
public boolean selectWithKeyChar(char keyChar)
selectWithKeyChar
in class JComboBox
public void undelegateKeyStrokes()
DelegateAction.restoreAction(javax.swing.JComponent,
int, javax.swing.KeyStroke)
.
delegateKeyStrokes()
public List<KeyStroke> getDelegateKeyStrokes()
public String convertElementToString(Object value, Class clazz)
public String convertElementToString(Object value)
public Object convertStringToElement(String text)
public Object convertStringToElement(String text, Class clazz)
public ObjectConverter getConverter()
public void setConverter(ObjectConverter converter)
public ConverterContext getConverterContext()
ConverterContextSupport
getConverterContext
in interface ConverterContextSupport
public void setConverterContext(ConverterContext converterContext)
ConverterContextSupport
setConverterContext
in interface ConverterContextSupport
converterContext
- converter contextpublic Class<?> getType()
ConverterContextSupport
getType
in interface ConverterContextSupport
public void setType(Class<?> clazz)
ConverterContextSupport
setType
in interface ConverterContextSupport
public boolean isPopupVolatile()
public void setPopupVolatile(boolean popupVolatile)
popupVolatile
- true or falsepublic void setButtonVisible(boolean buttonVisible)
buttonVisible
- true to make popup button visible.public boolean isButtonVisible()
public void setButtonOnly(boolean buttonOnly)
createButtonComponent()
to create a button that is unique, such as a
date chooser icon if this is a DateComboBox. The default combobox button is not appropriate when only the button
is visible.
buttonOnly
- true to make only the popup button visible (and hide the editor area).public boolean isButtonOnly()
public int getPopupType()
public void setPopupType(int popupType)
popupType
- the new popup type.public int getPopupLocation()
public void setPopupLocation(int popupLocation)
public boolean isStretchToFit()
public void setStretchToFit(boolean stretchToFit)
stretchToFit
- true or false.public boolean isStretchToFitSet()
public boolean isKeepPopupSize()
public void setKeepPopupSize(boolean keepPopupSize)
keepPopupSize
- true or false.public void setFocusLostBehavior(int behavior)
ExComboBox.COMMIT
,
ExComboBox.COMMIT_OR_REVERT
, ExComboBox.REVERT
,
ExComboBox.PERSIST
, ExComboBox.COMMIT_OR_RESET
or
ExComboBox.RESET
. Note that some ObjectConverter
s may push changes as they occur,
so that the value of this will have no effect.
This will throw an IllegalArgumentException
if the object passed in is not one of the afore
mentioned values.
The default value of this property is ExComboBox.COMMIT_OR_REVERT
.
behavior
- Identifies behavior when focus is lost
IllegalArgumentException
- if behavior is not one of the known valuespublic int getFocusLostBehavior()
COMMIT
, COMMIT_OR_REVERT
,
REVERT
, PERSIST
, COMMIT_OR_RESET
or RESET
. Note that some
ObjectConverter
s may push changes as they occur, so that the value of this will have no effect.
public void setPopupCancelBehavior(int behavior)
ExComboBox.PERSIST
,
ExComboBox.REVERT
, or ExComboBox.RESET
.
The default value of this property is ExComboBox.REVERT
which means the value will be reset to
the previous value before the drop down is shown.
behavior
- Identifies behavior when the drop down popup is canceled.
IllegalArgumentException
- if behavior is not one of the known valuespublic int getPopupCancelBehavior()
PERSIST
,
REVERT
, or RESET
.
public void popupMenuCanceled(PopupMenuEvent e)
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
protected AbstractAction getDefaultOKAction()
protected AbstractAction getDefaultCancelAction()
protected boolean isUpdateFromPopupOnFly()
public Action getDialogOKAction()
public Action getDialogCancelAction()
public boolean isReallyFocusLost(FocusEvent e)
public void commitEditWithFocusLostBehavior(boolean commit)
commit
- true or false.protected void notifyUser()
public boolean isRetrievingValueFromPopup()
public boolean commitEdit()
public void revertEdit()
protected boolean comboBoxSelected()
protected void installColorFontAndBorder(JTable table, boolean isSelected, boolean hasFocus, int row, int column)
public void resetEdit()
public boolean processKeyBinding(KeyStroke keyStroke, KeyEvent keyEvent, int i, boolean b)
processKeyBinding
in class JComponent
public void customizeDialogLocation(JDialog dialog)
dialog
- the dialogpublic void customizeDialog(JDialog dialog)
dialog
- the dialogpublic void customizePopup(JidePopup popup, PopupPanel panel)
popup
- the JidePopuppanel
- the popup panelpublic void fireActionEvent()
fireActionEvent
in class JComboBox
public boolean isEmptyStringNull()
setEmptyStringNull(boolean)
public void setEmptyStringNull(boolean emptyStringNull)
getType()
returns String.class.
emptyStringNull
- the flagpublic void setModel(ComboBoxModel aModel)
setModel
in class JComboBox
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |