public class IlvJComboBox extends JComboBox
JComboBox
that
contains workarounds against Swing globalization bugs.
Depending on the renderer
that you install on
an instance of this class, you may have to do additional coding in order
to get the component orientation of the list items correct:
renderer
, there is
nothing else to do: The IlvJComboBox
ensures the correct
component orientation.renderer
that does not
paint text and that is independent of the component orientation,
there is nothing else to do either.renderer
with a
getListCellRendererComponent
method that propagates the
component orientation from the JList
argument to the
rendering component, there is nothing else to do either.renderer
with a
getListCellRendererComponent
method that does not
propagate the component orientation, then if that renderer is a
subclass of JLabel
, you can use
setCustomJLabelBasedRendering(true)
to have the
component orientation propagated to the renderer.JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
IlvJComboBox()
Creates a new empty
JComboBox . |
IlvJComboBox(ComboBoxModel model)
Creates a new
IlvJComboBox with a specific combo box model. |
IlvJComboBox(Object[] items)
Creates a new
IlvJComboBox that contains the items
in the specified array. |
IlvJComboBox(Vector<?> items)
Creates a new
IlvJComboBox that contains the items
in the specified Vector. |
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener listener)
Adds an
ActionListener that will be notified when the user
selects an item in this combination box, potentially with a small delay
(depending on platform and JVM parameters). |
void |
addUndelayedActionListener(ActionListener listener)
Adds an
ActionListener that will be notified immediately when
the user selects an item in this combination box. |
protected Object |
defaultRendererAdaptedValue(Object value)
Returns the value that is rendered by the default renderer.
|
Dimension |
getPreferredSize()
Returns the preferred size of this combination box.
|
boolean |
isCustomJLabelBasedRendering()
Returns whether the component orientation workaround is used for a
custom renderer that is a subclass of
JLabel . |
void |
setComponentOrientation(ComponentOrientation o)
Sets the language-sensitive orientation that is to be used to order
the elements or text within this component.
|
void |
setCustomJLabelBasedRendering(boolean use)
Sets whether the component orientation workaround is used for a
custom renderer that is a subclass of
JLabel . |
void |
setRenderer(ListCellRenderer renderer)
Sets the renderer that paints the list items and the item selected
from the list in the JComboBox field.
|
actionPerformed, actionPropertyChanged, 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, processKeyBinding, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setSelectedIndex, setSelectedItem, setUI, showPopup, updateUI
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, 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, update
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, transferFocusDownCycle, validate, validateTree
action, 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, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public IlvJComboBox(ComboBoxModel model)
IlvJComboBox
with a specific combo box model.model
- the ComboBoxModel
that provides the
displayed list of itemspublic IlvJComboBox(Object[] items)
IlvJComboBox
that contains the items
in the specified array.items
- an array of objects to insert into the combo boxpublic IlvJComboBox(Vector<?> items)
IlvJComboBox
that contains the items
in the specified Vector.items
- an array of vectors to insert into the combo boxpublic IlvJComboBox()
JComboBox
.public void setCustomJLabelBasedRendering(boolean use)
JLabel
.
This is disabled by default.
The component orientation problem results in wrong alignments in
right to left orientation in certain older Swing UIs.
By default, the renderer installed by the UI is modified to solve
the component orientation problem. This however does not work
for custom renderers that are set explicitly. In this case,
the custom renderer must support right to left component
orientation. For a custom renderer that does not support it but is
a subclass of JLabel
, this convenience option can be
enabled before setting the component orientation on the combo box.
In this case, the horizontal alignment of the label is modified
to be right when the component orientation is right to left.
public boolean isCustomJLabelBasedRendering()
JLabel
.public void setComponentOrientation(ComponentOrientation o)
setComponentOrientation
in class Component
public void setRenderer(ListCellRenderer renderer)
setRenderer
in class JComboBox
protected Object defaultRendererAdaptedValue(Object value)
value
- The original value.public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public void addActionListener(ActionListener listener)
ActionListener
that will be notified when the user
selects an item in this combination box, potentially with a small delay
(depending on platform and JVM parameters).addActionListener
in class JComboBox
listener
- An action listener.public void addUndelayedActionListener(ActionListener listener)
ActionListener
that will be notified immediately when
the user selects an item in this combination box.
This is equivalent to JComboBox.addActionListener(ActionListener)
.
listener
- An action listener.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.