gate.swing
Class JChoice
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
gate.swing.JChoice
- All Implemented Interfaces:
- ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible
public class JChoice
- extends JPanel
- implements ItemSelectable
A GUI component intended to allow quick selection from a set of
options. When the number of choices is small (i.e less or equal to
maximumFastChoices
) then the options are represented as a
set of buttons in a flow layout. If more options are available, a
simple JComboBox
is used instead.
- See Also:
- Serialized Form
Constructor Summary |
JChoice()
Creates a FastChoice with a default empty data model. |
JChoice(ComboBoxModel model)
Creates a FastChoice with the given data model. |
JChoice(Object[] items)
Creates a FastChoice with a default data model populated from the provided
array of objects. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, 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, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
DEFAULT_MAX_WIDTH
public static final int DEFAULT_MAX_WIDTH
- The default value for the
maximumWidth
parameter.
- See Also:
- Constant Field Values
DEFAULT_MAX_FAST_CHOICES
public static final int DEFAULT_MAX_FAST_CHOICES
- The default value for the
maximumFastChoices
parameter.
- See Also:
- Constant Field Values
JChoice
public JChoice()
- Creates a FastChoice with a default empty data model.
JChoice
public JChoice(ComboBoxModel model)
- Creates a FastChoice with the given data model.
JChoice
public JChoice(Object[] items)
- Creates a FastChoice with a default data model populated from the provided
array of objects.
getSelectedObjects
public Object[] getSelectedObjects()
- Specified by:
getSelectedObjects
in interface ItemSelectable
main
public static void main(String[] args)
removeActionListener
public void removeActionListener(ActionListener l)
- Parameters:
l
- - See Also:
JComboBox.removeActionListener(java.awt.event.ActionListener)
removeItemListener
public void removeItemListener(ItemListener listener)
- Specified by:
removeItemListener
in interface ItemSelectable
- Parameters:
listener
- - See Also:
JComboBox.removeItemListener(java.awt.event.ItemListener)
addActionListener
public void addActionListener(ActionListener l)
- Parameters:
l
- - See Also:
JComboBox.addActionListener(java.awt.event.ActionListener)
addItemListener
public void addItemListener(ItemListener listener)
- Specified by:
addItemListener
in interface ItemSelectable
- Parameters:
listener
- - See Also:
JComboBox.addItemListener(java.awt.event.ItemListener)
addListDataListener
public void addListDataListener(ListDataListener l)
- Parameters:
l
- - See Also:
ListModel.addListDataListener(javax.swing.event.ListDataListener)
getElementAt
public Object getElementAt(int index)
- See Also:
ListModel.getElementAt(int)
getSelectedItem
public Object getSelectedItem()
- See Also:
ComboBoxModel.getSelectedItem()
getItemCount
public int getItemCount()
- See Also:
ListModel.getSize()
removeListDataListener
public void removeListDataListener(ListDataListener l)
- Parameters:
l
- - See Also:
ListModel.removeListDataListener(javax.swing.event.ListDataListener)
setSelectedItem
public void setSelectedItem(Object anItem)
- Parameters:
anItem
- - See Also:
ComboBoxModel.setSelectedItem(java.lang.Object)
getPreferredSize
public Dimension getPreferredSize()
- Overrides:
getPreferredSize
in class JComponent
getMaximumFastChoices
public int getMaximumFastChoices()
- Returns:
- the maximumFastChoices
setMaximumFastChoices
public void setMaximumFastChoices(int maximumFastChoices)
- Parameters:
maximumFastChoices
- the maximumFastChoices to set
getModel
public ComboBoxModel getModel()
- Returns:
- the model
setModel
public void setModel(ComboBoxModel model)
- Parameters:
model
- the model to set
getMaximumWidth
public int getMaximumWidth()
- Returns:
- the maximumWidth
setMaximumWidth
public void setMaximumWidth(int maximumWidth)
- Parameters:
maximumWidth
- the maximumWidth to set
getDefaultButtonMargin
public Insets getDefaultButtonMargin()
- Returns:
- the defaultButtonMargin
setDefaultButtonMargin
public void setDefaultButtonMargin(Insets defaultButtonMargin)
- Parameters:
defaultButtonMargin
- the defaultButtonMargin to set