swingwtx.custom
Class JLookupPopup

java.lang.Object
  extended byswingwt.awt.Component
      extended byswingwt.awt.Container
          extended byswingwtx.swing.JComponent
              extended byswingwtx.swing.JPanel
                  extended byswingwtx.custom.JLookupPopup
All Implemented Interfaces:
ImageObserver, MenuContainer

public class JLookupPopup
extends JPanel

Very similar to JComboBox, this component is an uneditable text field with a button instead to popup a list of selectable items. A field at the top of the popup allows text searching. In addition, hotkeys in the text field allow searching like a combo box. I have designed this as a fast alternative for JComboBox as I discovered JComboBox performs very poorly under Linux/GTK2 with 200+ objects


Nested Class Summary
 
Nested classes inherited from class swingwtx.swing.JComponent
JComponent.InternalFrameSelectionListener
 
Field Summary
protected  JButton button
           
protected static int CANCELED
           
protected static int INVISIBLE
           
protected  java.util.Vector itemListeners
          Item events
protected  java.util.Vector items
          The list of selectable objects
protected  java.util.Vector popupListeners
          Popup menu events
protected  int selectedIndex
           
protected  JTextField text
           
protected static int VISIBLE
           
 
Fields inherited from class swingwtx.swing.JPanel
opaque, ppeer
 
Fields inherited from class swingwtx.swing.JComponent
accessibleContext, actionMap, ancestorInputMap, border, clientProperties, descendantHasPeer, focusInputMap, internalFrameAdapter, internalFrameParent, 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
JLookupPopup()
          Creates a new JLookupPopup
 
Method Summary
 void addFocusListener(FocusListener l)
          Add a KeyListener to this component
 void addItem(java.lang.Object item)
          Add a selection to the list
 void addItemListener(ItemListener l)
           
 void addKeyListener(KeyListener l)
          Add a KeyListener to this component
 void addPopupMenuListener(PopupMenuListener l)
           
protected  void alphaSearchItem(char cs)
          Performs an alpha search for the next item based on the key pressed
protected  void buttonPressed()
          Gets called when the user presses the button.
 java.lang.Object getItemAt(int index)
          Returns the item at a given position
 int getItemCount()
          Returns the number of items in the list
 JTextField getJTextField()
           
 int getSelectedIndex()
          Returns the selected item by it's index
 java.lang.Object getSelectedItem()
          Returns the selected item
 java.lang.String getToolTipText()
          Returns the tooltip text for the component
 void grabFocus()
          Forces keyboard focus to the component
 boolean isEnabled()
          Returns true if the lookup is enabled
protected  void nextItem()
           
protected  void previousItem()
           
 void processItemEvent(ItemEvent e)
           
 void processPopupMenuEvent(int id)
           
 void removeAllItems()
          Clears the list
 void removeFocusListener(FocusListener l)
          Remove an KeyListener from the component
 void removeItem(java.lang.Object item)
          Remove a selection from the list
 void removeItemListener(ItemListener l)
           
 void removeKeyListener(KeyListener l)
          Remove an KeyListener from the component
 void removePopupMenuListener(PopupMenuListener l)
           
 void requestFocus()
          Requests the component receives the focus
 void setEnabled(boolean b)
          Sets whether the lookup is enabled
 void setMaximumRowCount(int i)
          We don't care for this component - it just keeps compatibility with JComboBox
 void setSelectedIndex(int i)
          Sets the selected item in the list
 void setSelectedItem(java.lang.Object o)
          Sets the selected item
 void setToolTipText(java.lang.String tip)
          Sets the tooltiptext for the component
 
Methods inherited from class swingwtx.swing.JPanel
calculatePreferredSize, getHeight, getSize, getWidth, setBorder, setSwingWTParent
 
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, setDoubleBuffered, setInputMap, setMargin, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled
 
Methods inherited from class swingwt.awt.Container
addComponentToLayout, addContainerListener, debug_showContainmentTree, doAdd, doLayout, getComponent, 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, addInputMethodListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, componentOnlyDispose, computePreferredSize, contains, contains, createImage, createListenerArrayFromVector, createVolatileImage, dispatchEvent, getActionCommand, getAlignmentX, getAlignmentY, getBackground, getBounds, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getListeners, getLocation, getLocationOnScreen, getName, getPeer, getPeerSize, getSize, getSWTPeer, getToolkit, getTreeLock, getX, getY, hasFocus, hasSetFont, hide, imageUpdate, inside, 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, removeInputMethodListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, repaint, repaint, repaint, setActionCommand, setAlignmentX, setAlignmentY, setBackground, setBounds, setBounds, setCachedProperties, setComponentOrientation, setComponentRemoved, setCursor, setFocusable, setFocusTraversalKeysEnabled, setFont, setForeground, setHeight, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setSize, setSize, 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

items

protected java.util.Vector items
The list of selectable objects


popupListeners

protected java.util.Vector popupListeners
Popup menu events


itemListeners

protected java.util.Vector itemListeners
Item events


text

protected JTextField text

button

protected JButton button

selectedIndex

protected int selectedIndex

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

JLookupPopup

public JLookupPopup()
Creates a new JLookupPopup

Method Detail

addFocusListener

public void addFocusListener(FocusListener l)
Description copied from class: Component
Add a KeyListener to this component

Overrides:
addFocusListener in class Component

removeFocusListener

public void removeFocusListener(FocusListener l)
Description copied from class: Component
Remove an KeyListener from the component

Overrides:
removeFocusListener in class Component

addKeyListener

public void addKeyListener(KeyListener l)
Description copied from class: Component
Add a KeyListener to this component

Overrides:
addKeyListener in class Component

removeKeyListener

public void removeKeyListener(KeyListener l)
Description copied from class: Component
Remove an KeyListener from the component

Overrides:
removeKeyListener in class Component

addPopupMenuListener

public void addPopupMenuListener(PopupMenuListener l)

removePopupMenuListener

public void removePopupMenuListener(PopupMenuListener l)

addItemListener

public void addItemListener(ItemListener l)

removeItemListener

public void removeItemListener(ItemListener l)

processPopupMenuEvent

public void processPopupMenuEvent(int id)

processItemEvent

public void processItemEvent(ItemEvent e)

addItem

public void addItem(java.lang.Object item)
Add a selection to the list


removeItem

public void removeItem(java.lang.Object item)
Remove a selection from the list


getSelectedIndex

public int getSelectedIndex()
Returns the selected item by it's index


setSelectedIndex

public void setSelectedIndex(int i)
Sets the selected item in the list


setSelectedItem

public void setSelectedItem(java.lang.Object o)
Sets the selected item


getSelectedItem

public java.lang.Object getSelectedItem()
Returns the selected item


getItemCount

public int getItemCount()
Returns the number of items in the list


getItemAt

public java.lang.Object getItemAt(int index)
Returns the item at a given position


removeAllItems

public void removeAllItems()
Clears the list


setEnabled

public void setEnabled(boolean b)
Sets whether the lookup is enabled

Overrides:
setEnabled in class Component

isEnabled

public boolean isEnabled()
Returns true if the lookup is enabled

Overrides:
isEnabled in class Component

getToolTipText

public java.lang.String getToolTipText()
Returns the tooltip text for the component

Overrides:
getToolTipText in class Component

setToolTipText

public void setToolTipText(java.lang.String tip)
Sets the tooltiptext for the component

Overrides:
setToolTipText in class Component

setMaximumRowCount

public void setMaximumRowCount(int i)
We don't care for this component - it just keeps compatibility with JComboBox


buttonPressed

protected void buttonPressed()
Gets called when the user presses the button. The dialog should be popped up to prompt the user for a new selection.


previousItem

protected void previousItem()

nextItem

protected void nextItem()

alphaSearchItem

protected void alphaSearchItem(char cs)
Performs an alpha search for the next item based on the key pressed


requestFocus

public void requestFocus()
Description copied from class: Component
Requests the component receives the focus

Overrides:
requestFocus in class Component

grabFocus

public void grabFocus()
Description copied from class: Component
Forces keyboard focus to the component

Overrides:
grabFocus in class Component

getJTextField

public JTextField getJTextField()