JIDE 3.5.15

com.jidesoft.combobox
Class PopupPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.jidesoft.combobox.PopupPanel
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
ButtonPopupPanel, CalculatorPopupPanel, ColorChooserPanel, DateChooserPanel, FileChooserPanel, FileNameChooserPanel, FolderChooserPanel, FolderNameChooserPanel, ListChooserPanel, MonthChooserPanel, MultilineStringPopupPanel, StringArrayPopupPanel, TableChooserPanel, TreeChooserPanel

public class PopupPanel
extends JPanel
implements ItemSelectable

This PopupPanel is part of AbstractComboBox. ComboBox usually needs a popup panel, either as drop down or a dialog. In either case, it is used to select something. All subclasses of AbstractComboBox should use PopupPanel or subclass of PopupPanel to create a panel that can be used by AbstractComboBox.
PopupPanel extends JPanel. In addition, it implements ItemSelectable interface. It also can take ItemListener so that any selection change event can be fired.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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
protected  Object _previousSelectedObject
           
static String SELECTED_BY_MOUSE_ROLLOVER
           
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PopupPanel()
          Creates a PopupPanel with FlowLayout.
PopupPanel(LayoutManager layout)
          Creates a PopupPanel with the specified layout.
 
Method Summary
 void addItemListener(ItemListener l)
          Adds an ItemListener.
 void addItemListener(ItemListener l, int index)
          Adds an ItemListener.
protected  void fireItemStateChanged(ItemEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
 Dimension getActualPreferredSize()
           
 Component getDefaultFocusComponent()
          Gets the default focus component.
 ItemListener[] getItemListeners()
          Returns an array of all the ItemListeners added to this JComboBox with addItemListener().
 MouseListener getMouseListener()
           
 MouseMotionListener getMouseMotionListener()
           
 Dimension getPreferredSize()
           
 Object getPreviousSelectedObject()
          Gets the previously selected object.
 int getResizableCorners()
          Gets the resizable corners.
 Object getSelectedObject()
          Gets the selected object.
 Object[] getSelectedObjects()
          Returns the selected items or null if no items are selected.
 String getTitle()
          Gets the title of the popup panel.
 boolean isResetButtonVisible()
          Checks if reset button is visible when popup panel is display in dialog in DIALOG type AbstractComboBox.
 boolean isResizable()
          Checks if popup panel is resizable.
 boolean isStretchToFit()
          Checks if the popup panel should be stretched be the same width as the combobox.
 boolean needsButtons()
          Some popup panel doesn't have a OK or Cancel button to confirm the selection.
 void removeAllListeners()
          Removes all listeners it created.
 void removeItemListener(ItemListener aListener)
          Removes an ItemListener.
 void requestFocus()
           
 void setDefaultFocusComponent(Component defaultFocusComponent)
          Sets the default focus component.
 void setNeedButtons(boolean needButtons)
          Configure if buttons are needed.
 void setPreferredSize(Dimension preferredSize)
           
 void setResizable(boolean resizable)
          Sets the resizable property.
 void setResizableCorners(int resizableCorners)
          Sets resizable corners.
 void setSelectedObject(Object selectedObject)
          Sets the selected object and fire ItemEvent.
 void setSelectedObject(Object selectedObject, AbstractComboBox comboBox)
          Deprecated. replaced by setSelectedObject(Object)
 void setSelectedObject(Object selectedObject, AbstractComboBox comboBox, boolean fireEvent)
          Deprecated. replaced by setSelectedObject(Object, boolean)
 void setSelectedObject(Object selectedObject, boolean fireEvent)
          Sets the selected object and fire ItemEvent.
 void setStretchToFit(boolean stretchToFit)
          Sets the flag if the popup panel should be stretched or shrunk to be the same width as the combobox.
 void setTitle(String title)
          Sets the title of the popup panel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, 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, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELECTED_BY_MOUSE_ROLLOVER

public static final String SELECTED_BY_MOUSE_ROLLOVER
See Also:
Constant Field Values

_previousSelectedObject

protected Object _previousSelectedObject
Constructor Detail

PopupPanel

public PopupPanel()
Creates a PopupPanel with FlowLayout.


PopupPanel

public PopupPanel(LayoutManager layout)
Creates a PopupPanel with the specified layout.

Parameters:
layout - the layout
Method Detail

getSelectedObject

public Object getSelectedObject()
Gets the selected object.

Returns:
the selected object

removeAllListeners

public void removeAllListeners()
Removes all listeners it created. It should only be invoked by ExComboBoxPopup when the popup is reset. You should not invoke this method at any circumstance.

Since:
3.5.8

setSelectedObject

public void setSelectedObject(Object selectedObject)
Sets the selected object and fire ItemEvent. It will still fire event even the new selected object is the same as old selected object.

Parameters:
selectedObject - new selected object

setSelectedObject

public void setSelectedObject(Object selectedObject,
                              boolean fireEvent)
Sets the selected object and fire ItemEvent. It will still fire event even the new selected object is the same as old selected object.

Parameters:
selectedObject - new selected object
fireEvent - if fire the ItemEvent

setSelectedObject

@Deprecated
public void setSelectedObject(Object selectedObject,
                                         AbstractComboBox comboBox)
Deprecated. replaced by setSelectedObject(Object)

Sets the selected object and fire ItemEvent. It will still fire event even the new selected object is the same as old selected object.

Parameters:
selectedObject - new selected object
comboBox - the corresponding combo box instance

setSelectedObject

@Deprecated
public void setSelectedObject(Object selectedObject,
                                         AbstractComboBox comboBox,
                                         boolean fireEvent)
Deprecated. replaced by setSelectedObject(Object, boolean)

Sets the selected object and fire ItemEvent. It will still fire event even the new selected object is the same as old selected object.

Parameters:
selectedObject - new selected object
comboBox - the corresponding comboBox instance
fireEvent - if fire the ItemEvent for popupPanel. It will fire ItemEvent for comboBox anyway

addItemListener

public void addItemListener(ItemListener l)
Adds an ItemListener.

aListener will receive one or two ItemEvents when the selected item changes.

Specified by:
addItemListener in interface ItemSelectable
Parameters:
l - the ItemListener that is to be notified
See Also:
setSelectedObject(java.lang.Object)

addItemListener

public void addItemListener(ItemListener l,
                            int index)
Adds an ItemListener.

aListener will receive one or two ItemEvents when the selected item changes.

Parameters:
l - the ItemListener that is to be notified
index - the index of the ItemListener
See Also:
setSelectedObject(java.lang.Object)

removeItemListener

public void removeItemListener(ItemListener aListener)
Removes an ItemListener.

Specified by:
removeItemListener in interface ItemSelectable
Parameters:
aListener - the ItemListener to remove
See Also:
getItemListeners()

getItemListeners

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

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

fireItemStateChanged

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

Parameters:
e - the event of interest
See Also:
EventListenerList

getSelectedObjects

public Object[] getSelectedObjects()
Returns the selected items or null if no items are selected.

Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
the selected objects.

isStretchToFit

public boolean isStretchToFit()
Checks if the popup panel should be stretched be the same width as the combobox. Default is false.

Returns:
true or false.

setStretchToFit

public void setStretchToFit(boolean stretchToFit)
Sets the flag if the popup panel should be stretched or shrunk to be the same width as the combobox. Default is false.

Parameters:
stretchToFit - true or false.

needsButtons

public boolean needsButtons()
Some popup panel doesn't have a OK or Cancel button to confirm the selection. If so, when showing the popup panel in dialog, additional buttons such as "OK", "Cancel" and "Reset" will be added. So return true if this popup panel need those button; and false if no button is needed.
Default is true.

Returns:
true if those select buttons need to be added
See Also:
setNeedButtons(boolean)

setNeedButtons

public void setNeedButtons(boolean needButtons)
Configure if buttons are needed.

Parameters:
needButtons - the flag

isResetButtonVisible

public boolean isResetButtonVisible()
Checks if reset button is visible when popup panel is display in dialog in DIALOG type AbstractComboBox.

Returns:
true by default. Subclass can override this method to return false if reset button should be visible.

getDefaultFocusComponent

public Component getDefaultFocusComponent()
Gets the default focus component. The default focus component will gain focus when popup is shown.

Returns:
the default focus component.

setDefaultFocusComponent

public void setDefaultFocusComponent(Component defaultFocusComponent)
Sets the default focus component. The default focus component will gain focus when popup is shown.

Parameters:
defaultFocusComponent - a component inside the popup panel.

requestFocus

public void requestFocus()
Overrides:
requestFocus in class JComponent

getTitle

public String getTitle()
Gets the title of the popup panel. The title is used as the dialog title bar when the combobox is dialog popup.

Returns:
the title.

setTitle

public void setTitle(String title)
Sets the title of the popup panel. The title is used as the dialog title bar when the combobox is dialog popup.

Parameters:
title - title of the popup panel

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent

setPreferredSize

public void setPreferredSize(Dimension preferredSize)
Overrides:
setPreferredSize in class JComponent

getActualPreferredSize

public Dimension getActualPreferredSize()

isResizable

public boolean isResizable()
Checks if popup panel is resizable. This property is used in AbstractComboBox. If a popup panel is resizable, the drop down popup will be resizable. If AbstractComboBox is DIALOG type, the dialog will resizable.

Returns:
true if resizable.

setResizable

public void setResizable(boolean resizable)
Sets the resizable property.

Parameters:
resizable - true or false. True to make the popup panel resizable. If the popup panel is shown as popup, the popup will be resizable. If the popup panel is shown as a dialog, the dialog will be resizable.
See Also:
isResizable()

getResizableCorners

public int getResizableCorners()
Gets the resizable corners. The value is a bitwise OR of eight constants defined in Resizable.

Returns:
resizable corners.

setResizableCorners

public void setResizableCorners(int resizableCorners)
Sets resizable corners.

Parameters:
resizableCorners - new resizable corners. The value is a bitwise OR of eight constants defined in Resizable.

getMouseMotionListener

public MouseMotionListener getMouseMotionListener()

getMouseListener

public MouseListener getMouseListener()

getPreviousSelectedObject

public Object getPreviousSelectedObject()
Gets the previously selected object. This value is set when setSelectedObject(Object, boolean) is called with fireEvent parameter set to true.

Returns:
the previously selected object.

JIDE 3.5.15