|
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 com.jidesoft.combobox.AbstractComboBox
public abstract class AbstractComboBox
This class provides default implementation of any ComboBox-like component. With this class, you can fully customize the dropdown popup or even show popup as dialog. You can also customize the button and the text field to whatever you want. All you need is to create a class which extends AbstractComboBox
and implements several methods.
Any combobox-like component can be divided into several parts. They are an editor such as a JTextField, a button which shows the popup and a popup which will be shown when button is pressed.
There are also two types of ComboBox. One is the popup shown as drop down, same as JComboBox
. The other one is the popup shown as dialog such as a text field which can choose a file. So when you construct AbstractComboBox, you can pass in type either as DROPDOWN or as POPUP.
This class doesn't extend JComboBox. However all interfaces in JComboBox are divided into two parts and put in AbstractComboBox or ListComboBox,
whichever makes senses. So you shouldn't see much problem if converting existing JComboBox implementation to AbstractComboBox and ListComboBox implementation.
initComponent()
or initComponent(javax.swing.ComboBoxModel)
method in your ComboBox's constructor. We didn't call it automatically because we want you to decide when to call it during your ComboBox's initialization steps.
Nested Class Summary | |
---|---|
protected class |
AbstractComboBox.AccessibleJComboBox
This class implements accessibility support for the JComboBox class. |
static class |
AbstractComboBox.ComboBoxSpinner
|
static class |
AbstractComboBox.ComboBoxTextField
|
class |
AbstractComboBox.DefaultRendererComponent
|
class |
AbstractComboBox.DefaultTextFieldEditorComponent
Default EditorComponent which has a text field. |
class |
AbstractComboBox.EditorComponent
The EditorComponent is the one that used as editor. |
protected class |
AbstractComboBox.EnterLazyDelegateAction
|
protected class |
AbstractComboBox.LazyDelegateAction
|
class |
AbstractComboBox.SpinnerEditorComponent
Default EditorComponent which has a text field. |
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 | |
---|---|
protected StandardDialog |
_dialog
The dialog that will be shown. |
protected boolean |
_editable
This protected field is implementation specific. |
protected ComboBoxEditor |
_editor
This protected field is implementation specific. |
protected ListDataListener |
_listDataListener
|
protected Object |
_oldSelectedItemReminder
This protected field is implementation specific. |
protected AbstractButton |
_popupButton
The button that will show the popup. |
protected PopupPanel |
_popupPanel
The actual panel inside the PopupWindow. |
protected ListCellRenderer |
_renderer
This protected field is implementation specific. |
protected String |
actionCommand
This protected field is implementation specific. |
static String |
CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED
|
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. |
protected ComboBoxModel |
dataModel
This protected field is implementation specific. |
static int |
DIALOG
If the AbstractComboBox type is DIALOG, the popup panel will be shown as dialog. |
static int |
DROPDOWN
If the AbstractComboBox type is DROPDOWN, the popup panel will be shown as dropdown. |
protected Object |
HIDE_POPUP_KEY
|
static int |
PERSIST
Constant identifying that when focus is lost, the edited value should be left. |
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 AbstractComboBox . |
protected Object |
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 | |
---|---|
AbstractComboBox()
Creates a new DROPDOWN AbstractComboBox . |
|
AbstractComboBox(int type)
Creates a new AbstractComboBox with default context. |
|
AbstractComboBox(int type,
ConverterContext context)
Creates a new AbstractComboBox . |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
Has to make public due to implementation of an interface. |
void |
addActionListener(ActionListener l)
Adds an ActionListener . |
void |
addItemListener(ItemListener aListener)
Adds an ItemListener . |
void |
addNotify()
|
void |
addPopupMenuListener(PopupMenuListener l)
Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box. |
protected Point |
calculatePopupLocation()
calculate the popup location. |
protected boolean |
comboBoxSelected()
Check if this combo box is a selected cell inside a JTable. |
boolean |
commitEdit()
Commits the editing change to the AbstractComboBox. |
protected void |
commitEditWithFocusLostBehavior(boolean commit)
Conditionally commit the edit considering the focusLostBehavior. |
protected void |
configurePropertiesFromAction(Action a)
Factory method which sets the ActionEvent source's properties according to values from the Action instance. |
protected PropertyChangeListener |
createActionPropertyChangeListener(Action a)
Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance. |
AbstractButton |
createButtonComponent()
Subclass should override this method to create the actual button component. |
protected AbstractButton |
createDefaultButton()
Creates the default ComboBox button. |
abstract AbstractComboBox.EditorComponent |
createEditorComponent()
Subclass should implement this method to create the actual editor component. |
abstract PopupPanel |
createPopupComponent()
Subclass should implement this method to create the actual popup component. |
protected JidePopup |
createPopupWindow()
Creates the popup window. |
protected PropertyChangeListener |
createPropertyChangeListener()
|
protected JSpinner |
createSpinner()
Creates the spinner for the editor component of this ComboBox. |
protected JTextField |
createTextField()
Creates the text field for the editor component of this ComboBox. |
protected void |
customizeButton(AbstractButton button)
Customizes the button used by the AbstractComboBox. |
protected void |
customizeDialog(JDialog dialog)
Customizes the dialog. |
protected void |
customizeDialogLocation(JDialog dialog)
Customizes the dialog location. |
protected void |
customizePopup(JidePopup popup)
Customizes the JidePopup that is used to show the drop down. |
protected void |
delegateKeyStrokes()
Delegates key strokes to popup panel. |
protected boolean |
equals(Object object1,
Object object2)
Check if object1 is equal to object2. |
protected void |
fireActionEvent()
Notifies all listeners that have registered interest for notification on this event type without any check. |
protected void |
fireItemStateChanged(ItemEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
void |
firePopupMenuCanceled()
Notifies PopupMenuListener s that the popup portion of the combo box has been canceled. |
void |
firePopupMenuWillBecomeInvisible()
Notifies PopupMenuListener s that the popup portion of the combo box has become invisible. |
void |
firePopupMenuWillBecomeVisible()
Notifies PopupMenuListener s that the popup portion of the combo box will become visible. |
void |
focusGained(FocusEvent e)
|
void |
focusLost(FocusEvent e)
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JComboBox. |
Action |
getAction()
Returns the currently set Action for this ActionEvent source, or null if no Action is set. |
String |
getActionCommand()
Returns the _action command that is included in the event sent to _action listeners. |
ActionListener[] |
getActionListeners()
Returns an array of all the ActionListener s added to this JComboBox with addActionListener(). |
Color |
getBackground()
|
int |
getBaseline(int width,
int height)
|
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. |
protected List<KeyStroke> |
getDelegateKeyStrokes()
Gets the list of KeyStrokes that will be delegated to the popup panel. |
protected JComponent |
getDelegateTarget()
|
protected Action |
getDialogCancelAction()
Gets the cancel button action for the dialog type ComboBox. |
protected Action |
getDialogOKAction()
Gets the OK button action for the dialog type ComboBox. |
Color |
getDisabledBackground()
Gets the background color when the combobox is disabled. |
Color |
getDisabledForeground()
Gets the foreground color when the combobox is disabled. |
ComboBoxEditor |
getEditor()
Returns the editor used to paint and edit the selected item in the JComboBox field. |
int |
getFocusLostBehavior()
Returns the behavior when focus is lost. |
Color |
getForeground()
|
int |
getHorizontalAlignment()
Returns the horizontal alignment of the content. |
ItemListener[] |
getItemListeners()
Returns an array of all the ItemListener s added to this JComboBox with addItemListener(). |
ComboBoxModel |
getModel()
Returns the data model currently used by the JComboBox . |
AbstractButton |
getPopupButton()
Gets the button that will shows the popup. |
int |
getPopupCancelBehavior()
Returns the behavior when the popup drop down is canceled. |
int |
getPopupLocation()
Gets the popup location. |
PopupMenuListener[] |
getPopupMenuListeners()
Returns an array of all the PopupMenuListener s added to this JComboBox with addPopupMenuListener(). |
PopupPanel |
getPopupPanel()
Gets the popup panel. |
int |
getPopupType()
Gets the popup type. |
Object |
getPrototypeDisplayValue()
Returns the "prototypical display" value - an Object used for the calculation of the display height and width. |
ListCellRenderer |
getRenderer()
Returns the renderer used to display the selected item in the JComboBox field. |
Object |
getSelectedItem()
Returns the current selected item. |
protected Object |
getSelectedItemForPopupPanel()
Gets the selected item to setting into the popup panel before it's visible. |
Object[] |
getSelectedObjects()
Returns an array containing the selected item. |
Class<?> |
getType()
Gets the class of the value. |
int |
getVerticalAlignment()
Returns the vertical alignment of the content. |
void |
hidePopup()
Causes the combo box to close its popup window. |
protected void |
initComponent()
Initialize this component such as creating button, editor etc. |
protected void |
initComponent(ComboBoxModel model)
Initialize this component such as creating button, editor etc. |
protected void |
installColorFontAndBorder(JTable table,
boolean isSelected,
boolean hasFocus,
int row,
int column)
|
protected void |
installListener()
|
boolean |
isButtonOnly()
Checks if only the button is visible. |
boolean |
isButtonVisible()
Checks if the button is visible. |
boolean |
isClearSelectionOnListDataChanged()
Get the flag if AbstractComboBox should clear the current selection and field if it receives list data change event. |
boolean |
isEditable()
Returns true if the JComboBox is editable. |
boolean |
isHidePopupOnListDataChanged()
Get the flag if AbstractComboBox should hide popup if it receives list data change event. |
boolean |
isKeepPopupSize()
Checks if the popup size is kept when the popup is shown again. |
boolean |
isOpaque()
Override to always return true. |
boolean |
isPopupVisible()
Determines the visibility of the popup. |
boolean |
isPopupVolatile()
Checks if the popup is volatile. |
boolean |
isStretchToFit()
Checks if the popup panel should be stretched to be the same width as the ComboBox. |
boolean |
isToggleValueOnDoubleClick()
Checks if double click on the editor part will toggle the value. |
protected boolean |
isUpdateFromPopupOnFly()
This is a flag used internally. |
protected void |
listDataChanged()
The action on list data change events. |
protected void |
modelUpdated(ComboBoxModel model)
|
void |
mouseClicked(MouseEvent e)
|
void |
mouseEntered(MouseEvent e)
|
void |
mouseExited(MouseEvent e)
|
void |
mousePressed(MouseEvent e)
|
void |
mouseReleased(MouseEvent e)
|
protected void |
notifyUser()
Calls PortingUtils.notifyUser() to notify the user an error occurred when committing the edit. |
protected void |
paintComponent(Graphics g)
|
void |
popupMenuCanceled(PopupMenuEvent e)
|
void |
popupMenuWillBecomeInvisible(PopupMenuEvent e)
|
void |
popupMenuWillBecomeVisible(PopupMenuEvent e)
|
protected boolean |
processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed)
|
void |
removeActionListener(ActionListener l)
Removes an ActionListener . |
void |
removeItemListener(ItemListener aListener)
Removes an ItemListener . |
void |
removeNotify()
|
void |
removePopupMenuListener(PopupMenuListener l)
Removes a PopupMenuListener . |
void |
resetEdit()
Cancels the editing change and resets to null. |
void |
resetPopup()
Resets the popup. |
void |
revertEdit()
Cancels the editing change and reverts to the previous valid. |
protected void |
selectedItemChanged()
This protected method is implementation specific. |
void |
setAction(Action a)
Sets the Action for the ActionEvent source. |
void |
setActionCommand(String aCommand)
Sets the _action command that should be included in the event sent to _action listeners. |
void |
setBackground(Color fg)
|
void |
setBorder(Border border)
|
void |
setButtonOnly(boolean buttonOnly)
Sets the visibility of the editor and only makes the button visible. |
void |
setButtonVisible(boolean visible)
Sets the visibility of the button. |
void |
setClearSelectionOnListDataChanged(boolean clearSelectionOnListDataChanged)
Set the flag if AbstractComboBox should clear the current selection and field if it receives list data change event. |
void |
setConverter(ObjectConverter converter)
|
void |
setConverterContext(ConverterContext converterContext)
Sets the converter context. |
void |
setDisabledBackground(Color disabledBackground)
Sets the background color when the combobox is disabled. |
void |
setDisabledForeground(Color disabledForeground)
Sets the foreground color when the combobox is disabled. |
void |
setEditable(boolean editable)
Determines whether the JComboBox field is editable. |
void |
setEditor(ComboBoxEditor anEditor)
Deprecated. Please do not use this method for AbstractComboBox. If you need to provide your own editor, please override createEditorComponent() method instead. |
void |
setEnabled(boolean enabled)
|
void |
setFocusLostBehavior(int behavior)
Sets the behavior when focus is lost. |
void |
setForeground(Color fg)
|
void |
setHidePopupOnListDataChanged(boolean hidePopupOnListDataChanged)
Set the flag if AbstractComboBox should hide popup if it receives list data change event. |
void |
setHorizontalAlignment(int alignment)
Sets the horizontal alignment of the content. |
void |
setKeepPopupSize(boolean keepPopupSize)
Sets the flag if the popup size should be kept. |
void |
setModel(ComboBoxModel aModel)
Sets the data model that the JComboBox uses to obtain the list of items. |
void |
setPopupButton(AbstractButton button)
Sets the popup button. |
void |
setPopupCancelBehavior(int behavior)
Sets the behavior when the popup drop down is canceled. |
void |
setPopupType(int popupType)
Sets the popup type. |
void |
setPopupVisible(boolean v)
Sets the visibility of the popup. |
void |
setPopupVolatile(boolean popupVolatile)
Sets the volatile attribute of popup. |
void |
setPrototypeDisplayValue(Object prototypeDisplayValue)
Sets the prototype display value used to calculate the size of the display for the UI portion. |
void |
setRenderer(ListCellRenderer aRenderer)
Sets the renderer that paints the list items and the item selected from the list in the JComboBox field. |
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 |
setToggleValueOnDoubleClick(boolean toggleValueOnDoubleClick)
Sets the flag whether the value will be toggled when double clicking on the editor part. |
void |
setType(Class<?> clazz)
Sets the class of the value. |
void |
setVerticalAlignment(int alignment)
Sets the vertical alignment of the content. |
void |
showPopup()
Causes the combo box to display its popup window. |
protected void |
showPopupPanel()
Shows the popup panel. |
protected void |
showPopupPanelAsPopup(boolean show)
|
protected void |
undelegateKeyStrokes()
Undelegates keystrokes. |
protected void |
uninstallListener()
|
protected void |
updateToolTipTextForChildren()
|
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 |
---|
protected ComboBoxModel dataModel
getModel()
,
setModel(javax.swing.ComboBoxModel)
protected ComboBoxEditor _editor
getEditor()
,
setEditor(javax.swing.ComboBoxEditor)
protected boolean _editable
isEditable()
,
setEditable(boolean)
protected String actionCommand
setActionCommand(java.lang.String)
,
getActionCommand()
protected Object _oldSelectedItemReminder
protected Object selectedItemReminder
protected AbstractButton _popupButton
protected StandardDialog _dialog
protected PopupPanel _popupPanel
public static final int DROPDOWN
public static final int DIALOG
public static final String PROPERTY_SELECTED_ITEM
protected ListCellRenderer _renderer
getRenderer()
,
setRenderer(javax.swing.ListCellRenderer)
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 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
AbstractComboBox
.
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 RESET
setFocusLostBehavior(int)
,
Constant Field Valuesprotected ListDataListener _listDataListener
protected Object HIDE_POPUP_KEY
Constructor Detail |
---|
public AbstractComboBox()
AbstractComboBox
.
public AbstractComboBox(int type)
AbstractComboBox
with default context.
type
- DIALOG or DROPDOWNpublic AbstractComboBox(int type, ConverterContext context)
AbstractComboBox
.
type
- DIALOG or DROPDOWNcontext
- ConverterContextMethod Detail |
---|
public abstract AbstractComboBox.EditorComponent createEditorComponent()
public abstract PopupPanel createPopupComponent()
public AbstractButton createButtonComponent()
protected void initComponent()
initComponent(javax.swing.ComboBoxModel)
as it is guaranteed ?* to be called. this method is not called in the case of ListComboBox
.
public void updateUI()
updateUI
in class JComponent
public boolean isPopupVolatile()
public void setPopupVolatile(boolean popupVolatile)
popupVolatile
- true or falseprotected boolean comboBoxSelected()
public void resetPopup()
protected void initComponent(ComboBoxModel model)
model
- ComboBoxModel if any. If it's null, use InfiniteComboBoxModel.public void setEnabled(boolean enabled)
setEnabled
in class JComponent
protected void paintComponent(Graphics g)
paintComponent
in class JComponent
protected 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)
.
protected void undelegateKeyStrokes()
DelegateAction.restoreAction(javax.swing.JComponent,int,javax.swing.KeyStroke)
.
delegateKeyStrokes()
protected List<KeyStroke> getDelegateKeyStrokes()
protected void listDataChanged()
isHidePopupOnListDataChanged()
,
isClearSelectionOnListDataChanged()
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 void setButtonVisible(boolean visible)
visible
- 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()
protected PropertyChangeListener createPropertyChangeListener()
public boolean isHidePopupOnListDataChanged()
public void setHidePopupOnListDataChanged(boolean hidePopupOnListDataChanged)
hidePopupOnListDataChanged
- the flag if AbstractComboBox should hide popup if it receives list data change event.isHidePopupOnListDataChanged()
public boolean isClearSelectionOnListDataChanged()
public void setClearSelectionOnListDataChanged(boolean clearSelectionOnListDataChanged)
clearSelectionOnListDataChanged
- the flag if AbstractComboBox should clear current selection if it receives list data change event.isClearSelectionOnListDataChanged()
protected void updateToolTipTextForChildren()
protected JSpinner createSpinner()
AbstractComboBox.ComboBoxSpinner
to replace JSpinner. So if you ever override this createSpinner to create your own JSpinner, use ComboBoxSpinner instead. The only difference between JSpinner and ComboBoxSpinner is ComboBoxSpinner implements ProcessKeyBinding
interface and make processKeyBinding(...) a public method so that we can use it to pass the key event to it. Otherwise, you hit a key to start cell editing and the first key will get lost.
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
e
- the ActionEvent. Null if the event is actually fired by mousePressed event.public int getPopupType()
public void setPopupType(int popupType)
popupType
- the new popup type.protected void showPopupPanel()
protected void showPopupPanelAsPopup(boolean show)
show
- the flag that if we should really show the popup panelprotected Object getSelectedItemForPopupPanel()
getSelectedItem()
or _editor.getItem().
protected void customizePopup(JidePopup popup)
popup
- the JidePopup.protected JidePopup createPopupWindow()
protected Point calculatePopupLocation()
protected Action getDialogOKAction()
protected Action getDialogCancelAction()
protected void customizeDialogLocation(JDialog dialog)
dialog
- the dialogprotected void customizeDialog(JDialog dialog)
dialog
- the dialogpublic AbstractButton getPopupButton()
public void setPopupButton(AbstractButton button)
button
- a new popup button.public PopupPanel getPopupPanel()
public void setForeground(Color fg)
setForeground
in class JComponent
public void setBackground(Color fg)
setBackground
in class JComponent
public Object[] getSelectedObjects()
ItemSelectable
.
getSelectedObjects
in interface ItemSelectable
Objects
containing one element -- the selected itemprotected void fireItemStateChanged(ItemEvent e)
e
- the event of interestEventListenerList
public void setModel(ComboBoxModel aModel)
JComboBox
uses to obtain the list of items.
aModel
- the ComboBoxModel
that provides the displayed list of items description: Model that the combo box uses to get data to display.public ComboBoxModel getModel()
JComboBox
.
ComboBoxModel
that provides the displayed list of itemspublic void setEditable(boolean editable)
JComboBox
field is editable. An editable JComboBox
allows the user to type into the field or selected an item from the list to initialize the field, after which it can be edited. (The editing affects only the field, the list item remains intact.) A non editable JComboBox
displays the selected item in the field, but the selection cannot be modified.
editable
- a boolean value, where true indicates that the field is editable preferred: true description: If true, the user can type a new value in the combo box.public boolean isEditable()
JComboBox
is editable. By default, a combo box is not editable.
JComboBox
is editable, else false@Deprecated public void setEditor(ComboBoxEditor anEditor)
createEditorComponent()
method instead.
AbstractComboBox
field. The editor is used only if the receiving AbstractComboBox
is editable. If not editable, the combo box uses the renderer to paint the selected item.
anEditor
- the ComboBoxEditor
that displays the selected itempublic ComboBoxEditor getEditor()
JComboBox
field.
ComboBoxEditor
that displays the selected itempublic 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.
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.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.
setSelectedItem(java.lang.Object)
public Object getPrototypeDisplayValue()
prototypeDisplayValue
propertysetPrototypeDisplayValue(java.lang.Object)
public void setPrototypeDisplayValue(Object prototypeDisplayValue)
prototypeDisplayValue
- attribute: visualUpdate true description: The display prototype value, used to compute display width and height.getPrototypeDisplayValue()
public void showPopup()
setPopupVisible(boolean)
public void hidePopup()
setPopupVisible(boolean)
public void setPopupVisible(boolean v)
v
- visibilitypublic boolean isPopupVisible()
public void addItemListener(ItemListener aListener)
ItemListener
.
aListener
will receive one or two ItemEvent
s when the selected item changes.
addItemListener
in interface ItemSelectable
aListener
- the ItemListener
that is to be notifiedsetSelectedItem(java.lang.Object)
public void removeItemListener(ItemListener aListener)
ItemListener
.
removeItemListener
in interface ItemSelectable
aListener
- the ItemListener
to removepublic ItemListener[] getItemListeners()
ItemListener
s added to this JComboBox with addItemListener().
ItemListener
s added or an empty array if no listeners have been addedpublic void addActionListener(ActionListener l)
ActionListener
.
The ActionListener
will receive an ActionEvent
when a selection has been made. If the combo box is editable, then an ActionEvent
will be fired when editing has stopped.
l
- the ActionListener
that is to be notifiedsetSelectedItem(java.lang.Object)
public void removeActionListener(ActionListener l)
ActionListener
.
l
- the ActionListener
to removepublic ActionListener[] getActionListeners()
ActionListener
s added to this JComboBox with addActionListener().
ActionListener
s added or an empty array if no listeners have been addedpublic void addPopupMenuListener(PopupMenuListener l)
PopupMenu
listener which will listen to notification messages from the popup portion of the combo box.
For all standard look and feels shipped with Java 2, the popup list portion of combo box is implemented as a JPopupMenu
. A custom look and feel may not implement it this way and will therefore not receive the notification.
l
- the PopupMenuListener
to addpublic void removePopupMenuListener(PopupMenuListener l)
PopupMenuListener
.
l
- the PopupMenuListener
to removeaddPopupMenuListener(javax.swing.event.PopupMenuListener)
public PopupMenuListener[] getPopupMenuListeners()
PopupMenuListener
s added to this JComboBox with addPopupMenuListener().
PopupMenuListener
s added or an empty array if no listeners have been addedpublic void firePopupMenuWillBecomeVisible()
PopupMenuListener
s that the popup portion of the combo box will become visible.
This method is public but should not be called by anything other than the UI delegate.
addPopupMenuListener(javax.swing.event.PopupMenuListener)
public void firePopupMenuWillBecomeInvisible()
PopupMenuListener
s that the popup portion of the combo box has become invisible.
This method is public but should not be called by anything other than the UI delegate.
addPopupMenuListener(javax.swing.event.PopupMenuListener)
public void firePopupMenuCanceled()
PopupMenuListener
s that the popup portion of the combo box has been canceled.
This method is public but should not be called by anything other than the UI delegate.
addPopupMenuListener(javax.swing.event.PopupMenuListener)
public void setActionCommand(String aCommand)
aCommand
- a string containing the "command" that is sent to _action listeners; the same listener can then do different things depending on the command it receivespublic String getActionCommand()
protected void fireActionEvent()
EventListenerList
protected void selectedItemChanged()
public void setAction(Action a)
Action
for the ActionEvent
source. The new Action
replaces any previously set Action
but does not affect ActionListeners
independently added with addActionListener
. If the Action
is already a registered ActionListener
for the ActionEvent
source, it is not re-registered.
A side-effect of setting the Action
is that the ActionEvent
source's properties are immediately set from the values in the Action
(performed by the method configurePropertiesFromAction
) and subsequently updated as the Action
's properties change (via a PropertyChangeListener
created by the method createActionPropertyChangeListener
.
a
- the Action
for the JComboBox
, or null
. attribute: visualUpdate true description: the Action instance connected with this ActionEvent sourceAction
,
getAction()
,
configurePropertiesFromAction(javax.swing.Action)
,
createActionPropertyChangeListener(javax.swing.Action)
public Action getAction()
Action
for this ActionEvent
source, or null
if no Action
is set.
Action
for this ActionEvent
source; or null
Action
,
setAction(javax.swing.Action)
protected void configurePropertiesFromAction(Action a)
ActionEvent
source's properties according to values from the Action
instance. The properties which are set may differ for subclasses. By default, the properties which get set are Enabled
and ToolTipText
.
a
- the Action
from which to get the properties, or null
Action
,
setAction(javax.swing.Action)
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
PropertyChangeListener
used to update the ActionEvent
source as properties change on its Action
instance. Subclasses may override this in order to provide their own PropertyChangeListener
if the set of properties which should be kept up to date differs from the default properties (Text, Icon, Enabled, ToolTipText).
Note that PropertyChangeListeners
should avoid holding strong references to the ActionEvent
source, as this may hinder garbage collection of the ActionEvent
source and all components in its containment hierarchy.
a
- the action
public void popupMenuWillBecomeVisible(PopupMenuEvent e)
popupMenuWillBecomeVisible
in interface PopupMenuListener
public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
popupMenuWillBecomeInvisible
in interface PopupMenuListener
public void popupMenuCanceled(PopupMenuEvent e)
popupMenuCanceled
in interface PopupMenuListener
public void focusGained(FocusEvent e)
focusGained
in interface FocusListener
public void focusLost(FocusEvent e)
focusLost
in interface FocusListener
protected void commitEditWithFocusLostBehavior(boolean commit)
commit
- true or false.protected void notifyUser()
public boolean commitEdit()
public void revertEdit()
public void resetEdit()
public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
getAccessibleContext
in class JComponent
protected void installListener()
protected void uninstallListener()
protected AbstractButton createDefaultButton()
protected void customizeButton(AbstractButton button)
button
- the button component.public void removeNotify()
removeNotify
in class JComponent
public void addNotify()
addNotify
in class JComponent
protected JComponent getDelegateTarget()
protected JTextField createTextField()
AbstractComboBox.ComboBoxTextField
to replace JTextField. So if you ever override this createTextField to create your own JTextField, use ComboBoxTextField instead. The only difference between JTextField and ComboBoxTextField is ComboBoxTextField implements ProcessKeyBinding
interface and make processKeyBinding(...) a public method so that we can use it to pass the key event to it. Otherwise, you hit a key to start cell editing and the first key will get lost.
public boolean isOpaque()
isOpaque
in class JComponent
protected void installColorFontAndBorder(JTable table, boolean isSelected, boolean hasFocus, int row, int column)
public void setRenderer(ListCellRenderer aRenderer)
aRenderer.getListCellRendererComponent
is called, passing the list object and an index of -1.
aRenderer
- the ListCellRenderer
that displays the selected item expert: true description: The renderer that paints the item selected in the list.setEditor(javax.swing.ComboBoxEditor)
public ListCellRenderer getRenderer()
JComboBox
field.
ListCellRenderer
that displays the selected item.public int getPopupLocation()
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
processKeyBinding
in class JComponent
public int getBaseline(int width, int height)
getBaseline
in class JComponent
public void setFocusLostBehavior(int behavior)
AbstractComboBox.COMMIT
, AbstractComboBox.COMMIT_OR_REVERT
, AbstractComboBox.REVERT
, AbstractComboBox.PERSIST
, AbstractComboBox.COMMIT_OR_RESET
or AbstractComboBox.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 AbstractComboBox.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)
AbstractComboBox.PERSIST
, AbstractComboBox.REVERT
, or AbstractComboBox.RESET
.
The default value of this property is AbstractComboBox.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
.
protected void modelUpdated(ComboBoxModel model)
public boolean isToggleValueOnDoubleClick()
public void setToggleValueOnDoubleClick(boolean toggleValueOnDoubleClick)
toggleValueOnDoubleClick
- the flagpublic void setHorizontalAlignment(int alignment)
AlignmentSupport
AbstractButton
's default is SwingConstants.CENTER
,
but subclasses such as JCheckBox
may use a different default.
setHorizontalAlignment
in interface AlignmentSupport
alignment
- the alignment value, one of the following values:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
public int getHorizontalAlignment()
AlignmentSupport
AbstractButton
's default is SwingConstants.CENTER
,
but subclasses such as JCheckBox
may use a different default.
getHorizontalAlignment
in interface AlignmentSupport
horizontalAlignment
property,
one of the following values:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
public int getVerticalAlignment()
AlignmentSupport
getVerticalAlignment
in interface AlignmentSupport
verticalAlignment
property, one of the
following values:
SwingConstants.CENTER
(the default)
SwingConstants.TOP
SwingConstants.BOTTOM
public void setVerticalAlignment(int alignment)
AlignmentSupport
setVerticalAlignment
in interface AlignmentSupport
alignment
- one of the following values:
SwingConstants.CENTER
(the default)
SwingConstants.TOP
SwingConstants.BOTTOM
public void setBorder(Border border)
setBorder
in class JComponent
public boolean isStretchToFit()
public void setStretchToFit(boolean stretchToFit)
stretchToFit
- true or false.protected AbstractAction getDefaultOKAction()
protected AbstractAction getDefaultCancelAction()
protected boolean isUpdateFromPopupOnFly()
public Color getDisabledBackground()
public void setDisabledBackground(Color disabledBackground)
disabledBackground
- the background color when the combobox is disabled.public Color getDisabledForeground()
public void setDisabledForeground(Color disabledForeground)
disabledForeground
- the foreground color when the combobox is disabled.public Color getBackground()
getBackground
in class Component
public Color getForeground()
getForeground
in class Component
public boolean isKeepPopupSize()
public void setKeepPopupSize(boolean keepPopupSize)
keepPopupSize
- true or false.
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |