com.sibvisions.rad.ui.swing.ext
Class JVxChoice

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextField
                      extended by com.sibvisions.rad.ui.swing.ext.JVxChoice
All Implemented Interfaces:
JVxConstants, ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants
Direct Known Subclasses:
JVxChoiceRenderer

public class JVxChoice
extends JTextField
implements JVxConstants, ItemSelectable

A Choice editor can display and switch several values as Image. This is more flexible than JRadioButton or JCheckBox, because it can be configured which items should be returned and which images should be displayed instead.

See Also:
Serialized Form

Nested Class Summary
static class JVxChoice.NullCaret
          Null Caret is a invisible non functional Caret to prevent null pointer exceptions in swing.
static class JVxChoice.NullDocumentFilter
          Null Document Filter.
 
Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextField
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
 
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
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
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 com.sibvisions.rad.ui.swing.ext.JVxConstants
STRETCH
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JVxChoice()
          Constructs a new JVxChoice component.
JVxChoice(Object[] pAllowedValues, Image[] pImages)
          Constructs a new JVxChoice with the given allowed values and image names.
 
Method Summary
 void addActionListener(ActionListener pActionListener)
          Adds an ActionListener.
 void addItemListener(ItemListener pItemListener)
          
protected  void fireActionEvent()
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireItemStateChanged(ItemEvent pItemEvent)
          Notifies all listeners that have registered interest for notification on this event type.
 String getActionCommand()
          Returns the action command that is included in the event sent to action listeners.
 ActionListener[] getActionListeners()
          Returns an array of all the ActionListeners added to this JComboBox with addActionListener().
 Object[] getAllowedValues()
          Gets all allowed values.
 Color getBackground()
          
 Rectangle getBounds()
          
 Image getDefaultImage()
          Gets the default image that is shown if selectedIndex is -1.
 int getHeight()
          
 int getHorizontalAlignment()
          Gets the horizontal alignment of the icon.
 Image[] getImages()
          Gets the images that are used for displaying the values.
 Dimension getImageSize()
          Returns the image size.
 Color getInnerBackground()
          Gets the inner background.
 Border getInnerBorder()
          Gets the inner border.
 Rectangle getInnerBounds()
          Returns the inner bounds of the choice component.
 Insets getInnerInsets()
          Returns the inner insets.
 ItemListener[] getItemListeners()
          Returns an array of all the ItemListeners added to this JVxChoice with addItemListener().
 Dimension getPreferredSize()
          Gets the preferred size of the icon dependent of the configured alignments.
 int getSelectedIndex()
          Gets the selected index, or -1 if no value is selected.
 Object getSelectedItem()
          Gets the current selected value, or null, if no one is selected.
 Object[] getSelectedObjects()
          
 Dimension getSize()
          
 int getVerticalAlignment()
          Gets the vertical alignment of the icon.
 int getWidth()
          
 boolean isImageBorderVisible()
          Gets the visibility of the image border.
 void paintComponent(Graphics pGraphics)
          
protected  void processKeyEvent(KeyEvent pKeyEvent)
          
protected  void processMouseEvent(MouseEvent pMouseEvent)
          
 void removeActionListener(ActionListener pActionListener)
          Removes an ActionListener.
 void removeItemListener(ItemListener pItemListener)
          
 void selectNextIndex()
          Selects the next index.
 void setActionCommand(String pActionCommand)
          Sets the action command that should be included in the event sent to action listeners.
 void setAllowedValues(Object[] pAllowedValues)
          Sets all allowed values.
 void setCursor(Cursor pCursor)
          
 void setDefaultImage(Image pDefaultImage)
          Sets the default image that is shown if selectedIndex is -1.
 void setEditable(boolean pEditable)
          
 void setHorizontalAlignment(int pHorizontalAlignment)
          Sets the horizontal alignment of the icon.
 void setImageBorderVisible(boolean pImageBorderVisible)
          sets the visibility of the image border.
 void setImages(Image[] pImages)
          Sets the images that are used for displaying the values.
 void setImageSize(Dimension pImageSize)
          Returns the image size.
 void setInnerBackground(Color pInnerBackground)
          sets the inner background.
 void setInnerBorder(Border pInnerBorder)
          sets the inner border.
 void setSelectedIndex(int pSelectedIndex)
          Sets the selected index.
 void setSelectedItem(Object pSelectedItem)
          Sets the value that should be selected.
 void setUI(TextUI pTextUI)
          
 void setVerticalAlignment(int pVerticalAlignment)
          Sets the vertical alignment of the icon.
 
Methods inherited from class javax.swing.JTextField
actionPropertyChanged, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActions, getColumns, getColumnWidth, getHorizontalVisibility, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, scrollRectToVisible, setAction, setColumns, setDocument, setFont, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, updateUI, viewToModel, write
 
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, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, 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, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, 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
 

Constructor Detail

JVxChoice

public JVxChoice()
Constructs a new JVxChoice component.


JVxChoice

public JVxChoice(Object[] pAllowedValues,
                 Image[] pImages)
Constructs a new JVxChoice with the given allowed values and image names.

Parameters:
pAllowedValues - the allowed values.
pImages - the images.
Method Detail

setUI

public void setUI(TextUI pTextUI)

Overrides:
setUI in class JTextComponent

setCursor

public void setCursor(Cursor pCursor)

Overrides:
setCursor in class Component

setEditable

public void setEditable(boolean pEditable)

Overrides:
setEditable in class JTextComponent

getBackground

public Color getBackground()

Overrides:
getBackground in class Component

getWidth

public int getWidth()

Overrides:
getWidth in class JComponent

getHeight

public int getHeight()

Overrides:
getHeight in class JComponent

getSize

public Dimension getSize()

Overrides:
getSize in class Component

getBounds

public Rectangle getBounds()

Overrides:
getBounds in class Component

paintComponent

public void paintComponent(Graphics pGraphics)

Overrides:
paintComponent in class JComponent

getPreferredSize

public Dimension getPreferredSize()
Gets the preferred size of the icon dependent of the configured alignments. If an alignment is JVxConstants.STRETCH then the size of the component will be used. Otherwise the size of the image will be used.

Overrides:
getPreferredSize in class JTextField
Returns:
the preferred size of the image

getHorizontalAlignment

public int getHorizontalAlignment()
Gets the horizontal alignment of the icon.

Overrides:
getHorizontalAlignment in class JTextField
Returns:
the alignment
See Also:
JVxConstants

setHorizontalAlignment

public void setHorizontalAlignment(int pHorizontalAlignment)
Sets the horizontal alignment of the icon.

Overrides:
setHorizontalAlignment in class JTextField
Parameters:
pHorizontalAlignment - the alignment
See Also:
JVxConstants

processMouseEvent

protected void processMouseEvent(MouseEvent pMouseEvent)

Overrides:
processMouseEvent in class JComponent

processKeyEvent

protected void processKeyEvent(KeyEvent pKeyEvent)

Overrides:
processKeyEvent in class JComponent

getSelectedObjects

public Object[] getSelectedObjects()

Specified by:
getSelectedObjects in interface ItemSelectable

addItemListener

public void addItemListener(ItemListener pItemListener)

Specified by:
addItemListener in interface ItemSelectable

removeItemListener

public void removeItemListener(ItemListener pItemListener)

Specified by:
removeItemListener in interface ItemSelectable

getInnerBackground

public Color getInnerBackground()
Gets the inner background.

Returns:
the inner background.

setInnerBackground

public void setInnerBackground(Color pInnerBackground)
sets the inner background.

Parameters:
pInnerBackground - the inner background.

getInnerBorder

public Border getInnerBorder()
Gets the inner border.

Returns:
the inner border.

setInnerBorder

public void setInnerBorder(Border pInnerBorder)
sets the inner border.

Parameters:
pInnerBorder - the inner border.

isImageBorderVisible

public boolean isImageBorderVisible()
Gets the visibility of the image border.

Returns:
the visibility of the image border.

setImageBorderVisible

public void setImageBorderVisible(boolean pImageBorderVisible)
sets the visibility of the image border.

Parameters:
pImageBorderVisible - the visibility of the image border.

getAllowedValues

public Object[] getAllowedValues()
Gets all allowed values.

Returns:
all allowed values.

setAllowedValues

public void setAllowedValues(Object[] pAllowedValues)
Sets all allowed values.

Parameters:
pAllowedValues - all allowed values.

getImages

public Image[] getImages()
Gets the images that are used for displaying the values.

Returns:
the images.

setImages

public void setImages(Image[] pImages)
Sets the images that are used for displaying the values.

Parameters:
pImages - the images.

getImageSize

public Dimension getImageSize()
Returns the image size. The original size of the image.

Returns:
the size the images should have.

setImageSize

public void setImageSize(Dimension pImageSize)
Returns the image size. The original size of the image.

Parameters:
pImageSize - the size the images should have.

getInnerInsets

public Insets getInnerInsets()
Returns the inner insets.

Returns:
the inner insets.

getInnerBounds

public Rectangle getInnerBounds()
Returns the inner bounds of the choice component. Mouse events will only effect inside the inner bounds.

Returns:
the inner bounds.

getDefaultImage

public Image getDefaultImage()
Gets the default image that is shown if selectedIndex is -1.

Returns:
the default image.

setDefaultImage

public void setDefaultImage(Image pDefaultImage)
Sets the default image that is shown if selectedIndex is -1.

Parameters:
pDefaultImage - the default image.

getVerticalAlignment

public int getVerticalAlignment()
Gets the vertical alignment of the icon.

Returns:
the alignment
See Also:
JVxConstants

setVerticalAlignment

public void setVerticalAlignment(int pVerticalAlignment)
Sets the vertical alignment of the icon.

Parameters:
pVerticalAlignment - the alignment
See Also:
JVxConstants

getSelectedIndex

public int getSelectedIndex()
Gets the selected index, or -1 if no value is selected.

Returns:
the selected index.

setSelectedIndex

public void setSelectedIndex(int pSelectedIndex)
Sets the selected index. If the index does not exist, it is set to -1 (deselected).

Parameters:
pSelectedIndex - the index to select.

selectNextIndex

public void selectNextIndex()
Selects the next index. This functionality is round robin.


getSelectedItem

public Object getSelectedItem()
Gets the current selected value, or null, if no one is selected. Be careful, null can also be a allowed value.

Returns:
the selected value.

setSelectedItem

public void setSelectedItem(Object pSelectedItem)
Sets the value that should be selected. If the value i not included in the allowed values list, the selected index is set to -1. Be careful, null can also be a allowed value.

Parameters:
pSelectedItem - the value to select.

getActionCommand

public String getActionCommand()
Returns the action command that is included in the event sent to action listeners.

Returns:
the string containing the "command" that is sent to action listeners.

setActionCommand

public void setActionCommand(String pActionCommand)
Sets the action command that should be included in the event sent to action listeners.

Overrides:
setActionCommand in class JTextField
Parameters:
pActionCommand - a string containing the "command" that is sent to action listeners; the same listener can then do different things depending on the command it receives

getItemListeners

public ItemListener[] getItemListeners()
Returns an array of all the ItemListeners added to this JVxChoice with addItemListener().

Returns:
all of the ItemListeners added or an empty array if no listeners have been added

addActionListener

public void addActionListener(ActionListener pActionListener)
Adds an ActionListener.

The ActionListener will receive an ActionEvent when a selection has been made.

Overrides:
addActionListener in class JTextField
Parameters:
pActionListener - the ActionListener that is to be notified
See Also:
setSelectedItem(java.lang.Object)

removeActionListener

public void removeActionListener(ActionListener pActionListener)
Removes an ActionListener.

Overrides:
removeActionListener in class JTextField
Parameters:
pActionListener - the ActionListener to remove

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the ActionListeners added to this JComboBox with addActionListener().

Overrides:
getActionListeners in class JTextField
Returns:
all of the ActionListeners added or an empty array if no listeners have been added

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent pItemEvent)
Notifies all listeners that have registered interest for notification on this event type.

Parameters:
pItemEvent - the event of interest
See Also:
ItemListener

fireActionEvent

protected void fireActionEvent()
Notifies all listeners that have registered interest for notification on this event type.

See Also:
ActionListener


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.