Class JCarouselMenu
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.pushingpixels.radiance.theming.extras.internal.contrib.blogofbug.swing.components.GradientPanel
org.pushingpixels.radiance.theming.extras.internal.contrib.blogofbug.swing.components.JCarouselMenu
- All Implemented Interfaces:
ComponentListener, KeyListener, MouseListener, MouseWheelListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, ListSelectionListener
public class JCarouselMenu
extends GradientPanel
implements ListSelectionListener, MouseListener, KeyListener, ChangeListener, MouseWheelListener
Shows a carousel offset to the left with a menu of actions on the right.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classListCellRenderer for the Carousel uses an image border to draw a nice border around the menu item when it is selectedstatic classA menu item inside the carouselprivate classThis class represents the up and down buttons that allow the scrolling through the menu when it is too big to fit in the avaiable spaceNested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JCaroselThe carousel used and drawn on the left.private JCarouselMenu.UpDownButtonThe button shown when you can scroll downprivate intThe last item selectedprivate JListA JList with the menu items inprivate LinkedList<JCarouselMenu.MenuItem> Linked list of the items in the menuprivate Map<Component, JCarouselMenu.MenuItem> A hashtable connecting the actions to the components in the carouselprivate DefaultListModelThe model for the action menuprivate JScrollPaneThe scroll pane the menu is inprivate JCarouselMenu.UpDownButtonThe button that is drawn when it is possible to scroll upFields inherited from class GradientPanel
cache, end, gp, startFields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instanceJCarouselMenu(ImageBorder border) Creates a new instance of JCarouselMenu -
Method Summary
Modifier and TypeMethodDescriptionAdds a component to the carousel menu that will be brought into view when the user clicks on the associated itemAdds an image (with a label) and returns the component created to represent themDeprecated.Use add(Image, String) insteadAdds an image based on the imageURL and a text label, returning the component that is created as a resultDeprecated.Use add(imageURL, label) insteadAdds an action to the list, creating a menu item and a carousel entryDeprecated.Use add(imageURL) insteadgetList()Returns the list part of the carousel menuReturn the preferred size of the componentvoidkeyPressed(KeyEvent keyEvent) Listen for key events, when we see one that looks like it should wrap, set up the lastSelection variable to trigger a change on release of the keyvoidkeyReleased(KeyEvent keyEvent) If the wrap-around has detected the need to wrap, sets the selection to the value calculated when the key was first pressed.voidDon't Care *voidmouseClicked(MouseEvent mouseEvent) Look to see if an item in the list is double clicked, and launch the action if it isvoidmouseEntered(MouseEvent mouseEvent) Don't Care *voidmouseExited(MouseEvent mouseEvent) Don't Care *voidmousePressed(MouseEvent mouseEvent) Don't Care *voidmouseReleased(MouseEvent mouseEvent) Don't Care *voidmouseWheelMoved(MouseWheelEvent mouseWheelEvent) Moves the selected menu up or down when the mouse wheel scrollsprotected voidLaunch the action associated with the currently selected list itemvoidRemoves a component from the menuvoidsetCellImageBorder(ImageBorder imageBorder) Sets the image border used to draw around the items in the menuvoidsetCellRenderer(ListCellRenderer cellRenderer) Specifies the list cell renderer used to draw the items in the menuvoidsetMenuScrollColor(Color color) Allows the background color to the menu (left side) to be setvoidsetSelectedIndex(int i) Sets the selected item in the menuvoidsetUpDownColor(Color color) Sets the color the up and down buttons are drawnvoidsetUpDownIcons(Icon upIcon, Icon downIcon) Sets icons to use to show the up and down buttonsvoidDetect when the list selection changes, and respond by updating the state of the two "arrow" buttons.voidvalueChanged(ListSelectionEvent listSelectionEvent) Detect when the list selection changes, and respond by rotating the carousel to show that itemMethods inherited from class GradientPanel
componentHidden, componentMoved, componentResized, componentShown, paintComponent, setBackground, setBackgroundMethods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class 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, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
carousel
The carousel used and drawn on the left. -
lastSelection
private int lastSelectionThe last item selected -
upButton
The button that is drawn when it is possible to scroll up -
downButton
The button shown when you can scroll down
-
-
Constructor Details
-
JCarouselMenu
Creates a new instance of JCarouselMenu- Parameters:
border- The border to use to draw items in the menu
-
JCarouselMenu
public JCarouselMenu()Creates a new instance
-
-
Method Details
-
setUpDownColor
Sets the color the up and down buttons are drawn- Parameters:
color- The desired color
-
getList
-
setSelectedIndex
public void setSelectedIndex(int i) Sets the selected item in the menu- Parameters:
i- The index of the item to select
-
add
-
remove
-
add
Deprecated.Use add(Image, String) insteadAdds an image to the menu.- Parameters:
image- The imagelabel- The textwidth- Prefered widthheight- Prefered height- Returns:
- The created component
-
add
-
add
Deprecated.Use add(imageURL) insteadAdds an action to the menu- Parameters:
action- The action to addwidth- The widthheight- The height- Returns:
- The created component
-
add
-
add
Deprecated.Use add(imageURL, label) insteadAdds an image (through a URL) to the menu- Parameters:
imageURL- URL of the imagelabel- Text messagewidth- widthheight- height- Returns:
- The created component
-
add
-
getPreferredSize
Return the preferred size of the component- Overrides:
getPreferredSizein classJComponent- Returns:
- The prefered dimensions of the component
-
stateChanged
Detect when the list selection changes, and respond by updating the state of the two "arrow" buttons. Contributed by Sebastian Charpentier.- Specified by:
stateChangedin interfaceChangeListener- Parameters:
e- The state changed event- See Also:
-
valueChanged
Detect when the list selection changes, and respond by rotating the carousel to show that item- Specified by:
valueChangedin interfaceListSelectionListener- Parameters:
listSelectionEvent- The list selection change event
-
processAction
protected void processAction()Launch the action associated with the currently selected list item -
mouseClicked
Look to see if an item in the list is double clicked, and launch the action if it is- Specified by:
mouseClickedin interfaceMouseListener- Parameters:
mouseEvent- The mouse event
-
mousePressed
Don't Care *- Specified by:
mousePressedin interfaceMouseListener- Parameters:
mouseEvent- The mouse event
-
mouseReleased
Don't Care *- Specified by:
mouseReleasedin interfaceMouseListener- Parameters:
mouseEvent- The mouse event
-
mouseEntered
Don't Care *- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
mouseEvent- The mouse event
-
mouseExited
Don't Care *- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
mouseEvent- The mouse event
-
keyTyped
Don't Care *- Specified by:
keyTypedin interfaceKeyListener- Parameters:
keyEvent- The key event
-
keyPressed
Listen for key events, when we see one that looks like it should wrap, set up the lastSelection variable to trigger a change on release of the key- Specified by:
keyPressedin interfaceKeyListener- Parameters:
keyEvent- The key event
-
setCellImageBorder
Sets the image border used to draw around the items in the menu- Parameters:
imageBorder- The desired image border
-
setCellRenderer
Specifies the list cell renderer used to draw the items in the menu- Parameters:
cellRenderer- The list cell renderer
-
keyReleased
If the wrap-around has detected the need to wrap, sets the selection to the value calculated when the key was first pressed.- Specified by:
keyReleasedin interfaceKeyListener- Parameters:
keyEvent- The key event
-
mouseWheelMoved
Moves the selected menu up or down when the mouse wheel scrolls- Specified by:
mouseWheelMovedin interfaceMouseWheelListener- Parameters:
mouseWheelEvent- The mouse wheel event
-
setUpDownIcons
-
setMenuScrollColor
Allows the background color to the menu (left side) to be set- Parameters:
color- Sets the background color to the menu
-