swingwtx.swing
Class JComboBox

java.lang.Object
  extended byswingwt.awt.Component
      extended byswingwt.awt.Container
          extended byswingwtx.swing.JComponent
              extended byswingwtx.swing.JComboBox
All Implemented Interfaces:
java.util.EventListener, ImageObserver, ListDataListener, MenuContainer

public class JComboBox
extends JComponent
implements ListDataListener


Nested Class Summary
 
Nested classes inherited from class swingwtx.swing.JComponent
JComponent.InternalFrameSelectionListener
 
Field Summary
protected static int CANCELED
           
protected  java.util.Vector changeListeners
           
protected static int INVISIBLE
           
protected  boolean isEditable
          Used to determine if the combo can be entered into
protected  java.util.Vector itemListeners
           
protected  java.util.Vector litems
           
protected  ComboBoxModel model
           
protected  int pMaxRows
           
protected  java.util.Vector popupListeners
           
protected  org.eclipse.swt.widgets.Combo ppeer
           
protected  int pSelectedIndex
           
protected  java.lang.String pText
           
protected static int VISIBLE
           
 
Fields inherited from class swingwtx.swing.JComponent
accessibleContext, actionMap, ancestorInputMap, border, clientProperties, descendantHasPeer, focusInputMap, internalFrameAdapter, internalFrameParent, opaque, propertyChangeListeners, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, windowInputMap
 
Fields inherited from class swingwt.awt.Container
composite, comps, containerListeners, layout, queuedValidateRequest
 
Fields inherited from class swingwt.awt.Component
actionCommand, actionListeners, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListeners, componentName, consumeAvailableHeight, consumeAvailableWidth, focusable, focusListeners, graphicsConfig, inputMethodListeners, isUserSetFont, keyListeners, layoutModifier, LEFT_ALIGNMENT, LOCK, mouseListeners, mouseMotionListeners, mouseWheelListeners, parent, pBackground, pCursor, pDoubleBuffered, peer, pEnabled, pFont, pForeground, pLayoutData, pLocation, pMaxSize, pMinSize, pPrefSize, pSize, pToolTipText, pVisible, RIGHT_ALIGNMENT, swingWTDefaultActionEventAdapter, swingWTEventAdapter, TOP_ALIGNMENT
 
Fields inherited from interface swingwt.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JComboBox()
           
JComboBox(ComboBoxModel model)
           
JComboBox(java.lang.Object[] items)
           
JComboBox(java.util.Vector items)
           
 
Method Summary
 void addChangeListener(ChangeListener l)
           
 void addItem(java.lang.Object item)
           
 void addItemListener(ItemListener l)
           
 void addPopupMenuListener(PopupMenuListener l)
           
 void contentsChanged(ListDataEvent e)
           
protected  void copyModel()
          Handles copying of Combo box models so they can be handled by SWT
 ChangeListener[] getChangeListeners()
           
 Component getComponent(int n)
           
 boolean getEditable()
           
 java.lang.Object getItemAt(int index)
           
 int getItemCount()
           
 ItemListener[] getItemListeners()
           
 int getMaximumRowCount()
           
 ComboBoxModel getModel()
           
 PopupMenuListener[] getPopupMenuListener()
           
 int getSelectedIndex()
           
 java.lang.Object getSelectedItem()
           
 java.lang.Object[] getSelectedObjects()
           
protected  void handleComboKeyStrokes()
          This routine will add the key handlers necessary for searching through combos by the key pressed (as Windows does, and as Swing does).
 void insertItemAt(java.lang.Object item, int index)
           
 void intervalAdded(ListDataEvent e)
           
 void intervalRemoved(ListDataEvent e)
           
 void processChangeEvent(ChangeEvent e)
           
 void processItemEvent(ItemEvent e)
           
 void processPopupMenuEvent(int id)
           
protected  void registerComboEvents()
           
 void removeAllItems()
           
 void removeChangeListener(ChangeListener l)
           
 void removeItem(java.lang.Object item)
           
 void removeItemAt(int index)
           
 void removeItemListener(ItemListener l)
           
 void removePopupMenuListener(PopupMenuListener l)
           
 void setEditable(boolean b)
           
 void setMaximumRowCount(int max)
           
 void setModel(ComboBoxModel model)
           
 void setSelectedIndex(int index)
           
 void setSelectedItem(java.lang.Object text)
           
 void setSwingWTParent(Container parent)
          Once a parent component receives an "add" call for a child, this being the child, this should be called to tell us to instantiate the peer and load in any cached properties.
 
Methods inherited from class swingwtx.swing.JComponent
add, add, add, add, add, addPropertyChangeListener, addPropertyChangeListener, checkInternalFrameChild, dispose, getAccessibleContext, getActionMap, getAutoscrolls, getBorder, getClientProperty, getInputMap, getInsets, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isValidateRoot, paint, paintBackground, paintChildren, paintComponent, paintImmediately, paintImmediately, putClientProperty, remove, remove, removePropertyChangeListener, removePropertyChangeListener, repaint, revalidate, scrollRectToVisible, setActionMap, setAutoscrolls, setBorder, setDoubleBuffered, setInputMap, setMargin, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled
 
Methods inherited from class swingwt.awt.Container
addComponentToLayout, addContainerListener, debug_showContainmentTree, doAdd, doLayout, getComponentCount, getComponentOrientation, getComponents, getComposite, getLayout, getMaximumSize, getMinimumSize, getParent, getPreferredSize, invalidate, minimumSize, preferredSize, processContainerEvent, processEvent, queuedValidate, removeAll, removeComponentFromCache, removeContainerListener, setLayout, setLayoutImpl, validate
 
Methods inherited from class swingwt.awt.Component
add, addActionListener, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, calculatePreferredSize, componentOnlyDispose, computePreferredSize, contains, contains, createImage, createListenerArrayFromVector, createVolatileImage, dispatchEvent, getActionCommand, getAlignmentX, getAlignmentY, getBackground, getBounds, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getListeners, getLocation, getLocationOnScreen, getName, getPeer, getPeerSize, getSize, getSize, getSWTPeer, getToolkit, getToolTipText, getTreeLock, getWidth, getX, getY, grabFocus, hasFocus, hasSetFont, hide, imageUpdate, inside, isEnabled, isFocusable, isMinimumSizeSet, isShowing, isVisible, processActionEvent, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, processTraverseEvent, registerActionEvents, registerComponentEvents, registerEvents, registerExtendedModifyEvents, registerFocusEvents, registerKeyEvents, registerModifyEvents, registerMouseEvents, registerPaintEvents, registerTraversalEvents, remove, removeActionListener, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, repaint, repaint, repaint, requestFocus, setActionCommand, setAlignmentX, setAlignmentY, setBackground, setBounds, setBounds, setCachedProperties, setComponentOrientation, setComponentRemoved, setCursor, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setFont, setForeground, setHeight, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setSize, setSize, setToolTipText, setVisible, setWidth, show, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ppeer

protected org.eclipse.swt.widgets.Combo ppeer

pText

protected java.lang.String pText

litems

protected java.util.Vector litems

pSelectedIndex

protected int pSelectedIndex

pMaxRows

protected int pMaxRows

popupListeners

protected java.util.Vector popupListeners

itemListeners

protected java.util.Vector itemListeners

changeListeners

protected java.util.Vector changeListeners

model

protected ComboBoxModel model

isEditable

protected boolean isEditable
Used to determine if the combo can be entered into


CANCELED

protected static final int CANCELED
See Also:
Constant Field Values

INVISIBLE

protected static final int INVISIBLE
See Also:
Constant Field Values

VISIBLE

protected static final int VISIBLE
See Also:
Constant Field Values
Constructor Detail

JComboBox

public JComboBox()

JComboBox

public JComboBox(java.lang.Object[] items)

JComboBox

public JComboBox(java.util.Vector items)

JComboBox

public JComboBox(ComboBoxModel model)
Method Detail

addChangeListener

public void addChangeListener(ChangeListener l)

removeChangeListener

public void removeChangeListener(ChangeListener l)

getChangeListeners

public ChangeListener[] getChangeListeners()

addPopupMenuListener

public void addPopupMenuListener(PopupMenuListener l)

removePopupMenuListener

public void removePopupMenuListener(PopupMenuListener l)

getPopupMenuListener

public PopupMenuListener[] getPopupMenuListener()

addItemListener

public void addItemListener(ItemListener l)

removeItemListener

public void removeItemListener(ItemListener l)

getItemListeners

public ItemListener[] getItemListeners()

processPopupMenuEvent

public void processPopupMenuEvent(int id)

processItemEvent

public void processItemEvent(ItemEvent e)

processChangeEvent

public void processChangeEvent(ChangeEvent e)

copyModel

protected void copyModel()
Handles copying of Combo box models so they can be handled by SWT


getSelectedItem

public java.lang.Object getSelectedItem()

getSelectedObjects

public java.lang.Object[] getSelectedObjects()

setSelectedItem

public void setSelectedItem(java.lang.Object text)

getModel

public ComboBoxModel getModel()

setModel

public void setModel(ComboBoxModel model)

addItem

public void addItem(java.lang.Object item)

insertItemAt

public void insertItemAt(java.lang.Object item,
                         int index)

getSelectedIndex

public int getSelectedIndex()

getItemAt

public java.lang.Object getItemAt(int index)

getComponent

public Component getComponent(int n)
Overrides:
getComponent in class Container

getItemCount

public int getItemCount()

setSelectedIndex

public void setSelectedIndex(int index)

removeAllItems

public void removeAllItems()

removeItem

public void removeItem(java.lang.Object item)

removeItemAt

public void removeItemAt(int index)

setEditable

public void setEditable(boolean b)

getEditable

public boolean getEditable()

getMaximumRowCount

public int getMaximumRowCount()

setMaximumRowCount

public void setMaximumRowCount(int max)

setSwingWTParent

public void setSwingWTParent(Container parent)
                      throws java.lang.Exception
Once a parent component receives an "add" call for a child, this being the child, this should be called to tell us to instantiate the peer and load in any cached properties.

Overrides:
setSwingWTParent in class JComponent
Throws:
java.lang.Exception

registerComboEvents

protected void registerComboEvents()

handleComboKeyStrokes

protected void handleComboKeyStrokes()
This routine will add the key handlers necessary for searching through combos by the key pressed (as Windows does, and as Swing does). This code really isn't too pretty, as SWT deactivates the key events if SWT.READ_ONLY is specified, so I have to handle that too, also you can't consume KeyEvents under a Combo (must be a bug), so I use a timer over the event pump to reset values. As I say, it's dirty but it works.


intervalAdded

public void intervalAdded(ListDataEvent e)
Specified by:
intervalAdded in interface ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Specified by:
intervalRemoved in interface ListDataListener

contentsChanged

public void contentsChanged(ListDataEvent e)
Specified by:
contentsChanged in interface ListDataListener