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:
java.awt.event.ComponentListener
,java.awt.event.KeyListener
,java.awt.event.MouseListener
,java.awt.event.MouseWheelListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
,javax.swing.event.ChangeListener
,javax.swing.event.ListSelectionListener
public class JCarouselMenu extends GradientPanel implements javax.swing.event.ListSelectionListener, java.awt.event.MouseListener, java.awt.event.KeyListener, javax.swing.event.ChangeListener, java.awt.event.MouseWheelListener
Shows a carousel offset to the left with a menu of actions on the right.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
JCarouselMenu.CarouselListCellRenderer
ListCellRenderer for the Carousel uses an image border to draw a nice border around the menu item when it is selectedstatic class
JCarouselMenu.MenuItem
A menu item inside the carouselprivate class
JCarouselMenu.UpDownButton
This class represents the up and down buttons that allow the scrolling through the menu when it is too big to fit in the avaiable space-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private JCarosel
carousel
The carousel used and drawn on the left.private JCarouselMenu.UpDownButton
downButton
The button shown when you can scroll downprivate int
lastSelection
The last item selectedprivate javax.swing.JList
menu
A JList with the menu items inprivate java.util.LinkedList<JCarouselMenu.MenuItem>
menuItems
Linked list of the items in the menuprivate java.util.Map<java.awt.Component,JCarouselMenu.MenuItem>
menuMap
A hashtable connecting the actions to the components in the carouselprivate javax.swing.DefaultListModel
menuModel
The model for the action menuprivate javax.swing.JScrollPane
menuScroll
The scroll pane the menu is inprivate JCarouselMenu.UpDownButton
upButton
The button that is drawn when it is possible to scroll up-
Fields inherited from class org.pushingpixels.radiance.theming.extras.internal.contrib.blogofbug.swing.components.GradientPanel
cache, end, gp, start
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description JCarouselMenu()
Creates a new instanceJCarouselMenu(ImageBorder border)
Creates a new instance of JCarouselMenu
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.awt.Component
add(java.awt.Component component, java.lang.String label)
Adds a component to the carousel menu that will be brought into view when the user clicks on the associated itemjava.awt.Component
add(java.awt.Image image, java.lang.String label)
Adds an image (with a label) and returns the component created to represent themjava.awt.Component
add(java.awt.Image image, java.lang.String label, int width, int height)
Deprecated.Use add(Image, String) insteadjava.awt.Component
add(java.lang.String imageURL, java.lang.String label)
Adds an image based on the imageURL and a text label, returning the component that is created as a resultjava.awt.Component
add(java.lang.String imageURL, java.lang.String label, int width, int height)
Deprecated.Use add(imageURL, label) insteadjava.awt.Component
add(javax.swing.Action action)
Adds an action to the list, creating a menu item and a carousel entryjava.awt.Component
add(javax.swing.Action action, int width, int height)
Deprecated.Use add(imageURL) insteadjavax.swing.JList
getList()
Returns the list part of the carousel menujava.awt.Dimension
getPreferredSize()
Return the preferred size of the componentvoid
keyPressed(java.awt.event.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 keyvoid
keyReleased(java.awt.event.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.void
keyTyped(java.awt.event.KeyEvent keyEvent)
Don't Care *void
mouseClicked(java.awt.event.MouseEvent mouseEvent)
Look to see if an item in the list is double clicked, and launch the action if it isvoid
mouseEntered(java.awt.event.MouseEvent mouseEvent)
Don't Care *void
mouseExited(java.awt.event.MouseEvent mouseEvent)
Don't Care *void
mousePressed(java.awt.event.MouseEvent mouseEvent)
Don't Care *void
mouseReleased(java.awt.event.MouseEvent mouseEvent)
Don't Care *void
mouseWheelMoved(java.awt.event.MouseWheelEvent mouseWheelEvent)
Moves the selected menu up or down when the mouse wheel scrollsprotected void
processAction()
Launch the action associated with the currently selected list itemvoid
remove(java.awt.Component component)
Removes a component from the menuvoid
setCellImageBorder(ImageBorder imageBorder)
Sets the image border used to draw around the items in the menuvoid
setCellRenderer(javax.swing.ListCellRenderer cellRenderer)
Specifies the list cell renderer used to draw the items in the menuvoid
setMenuScrollColor(java.awt.Color color)
Allows the background color to the menu (left side) to be setvoid
setSelectedIndex(int i)
Sets the selected item in the menuvoid
setUpDownColor(java.awt.Color color)
Sets the color the up and down buttons are drawnvoid
setUpDownIcons(javax.swing.Icon upIcon, javax.swing.Icon downIcon)
Sets icons to use to show the up and down buttonsvoid
stateChanged(javax.swing.event.ChangeEvent e)
Detect when the list selection changes, and respond by updating the state of the two "arrow" buttons.void
valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
Detect when the list selection changes, and respond by rotating the carousel to show that item-
Methods inherited from class org.pushingpixels.radiance.theming.extras.internal.contrib.blogofbug.swing.components.GradientPanel
componentHidden, componentMoved, componentResized, componentShown, paintComponent, setBackground, setBackground
-
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, 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, 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, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, 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 Detail
-
carousel
private JCarosel carousel
The carousel used and drawn on the left.
-
menu
private javax.swing.JList menu
A JList with the menu items in
-
menuScroll
private javax.swing.JScrollPane menuScroll
The scroll pane the menu is in
-
menuModel
private javax.swing.DefaultListModel menuModel
The model for the action menu
-
menuItems
private java.util.LinkedList<JCarouselMenu.MenuItem> menuItems
Linked list of the items in the menu
-
menuMap
private java.util.Map<java.awt.Component,JCarouselMenu.MenuItem> menuMap
A hashtable connecting the actions to the components in the carousel
-
lastSelection
private int lastSelection
The last item selected
-
upButton
private JCarouselMenu.UpDownButton upButton
The button that is drawn when it is possible to scroll up
-
downButton
private JCarouselMenu.UpDownButton downButton
The button shown when you can scroll down
-
-
Constructor Detail
-
JCarouselMenu
public JCarouselMenu(ImageBorder border)
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 Detail
-
setUpDownColor
public void setUpDownColor(java.awt.Color color)
Sets the color the up and down buttons are drawn- Parameters:
color
- The desired color
-
getList
public javax.swing.JList getList()
Returns the list part of the carousel menu- Returns:
- The JList object
-
setSelectedIndex
public void setSelectedIndex(int i)
Sets the selected item in the menu- Parameters:
i
- The index of the item to select
-
add
public java.awt.Component add(java.awt.Component component, java.lang.String label)
Adds a component to the carousel menu that will be brought into view when the user clicks on the associated item- Parameters:
component
- The componentlabel
- The text to appear in the menu- Returns:
- The created component
-
remove
public void remove(java.awt.Component component)
Removes a component from the menu- Overrides:
remove
in classjava.awt.Container
- Parameters:
component
- The component to remove
-
add
@Deprecated public java.awt.Component add(java.awt.Image image, java.lang.String label, int width, int height)
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
public java.awt.Component add(java.awt.Image image, java.lang.String label)
Adds an image (with a label) and returns the component created to represent them- Parameters:
image
- The image to displaylabel
- The label to show- Returns:
- The component created
-
add
@Deprecated public java.awt.Component add(javax.swing.Action action, int width, int height)
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
public java.awt.Component add(javax.swing.Action action)
Adds an action to the list, creating a menu item and a carousel entry- Parameters:
action
- The action to add- Returns:
- The resultant component
-
add
@Deprecated public java.awt.Component add(java.lang.String imageURL, java.lang.String label, int width, int height)
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
public java.awt.Component add(java.lang.String imageURL, java.lang.String label)
Adds an image based on the imageURL and a text label, returning the component that is created as a result- Parameters:
imageURL
- The URL of the imagelabel
- Text label to be shown in the menu- Returns:
- The created component
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Return the preferred size of the component- Overrides:
getPreferredSize
in classjavax.swing.JComponent
- Returns:
- The prefered dimensions of the component
-
stateChanged
public void stateChanged(javax.swing.event.ChangeEvent e)
Detect when the list selection changes, and respond by updating the state of the two "arrow" buttons. Contributed by Sebastian Charpentier.- Specified by:
stateChanged
in interfacejavax.swing.event.ChangeListener
- Parameters:
e
- The state changed event- See Also:
ChangeListener.stateChanged(javax.swing.event.ChangeEvent)
-
valueChanged
public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
Detect when the list selection changes, and respond by rotating the carousel to show that item- Specified by:
valueChanged
in interfacejavax.swing.event.ListSelectionListener
- Parameters:
listSelectionEvent
- The list selection change event
-
processAction
protected void processAction()
Launch the action associated with the currently selected list item
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
Look to see if an item in the list is double clicked, and launch the action if it is- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
- Parameters:
mouseEvent
- The mouse event
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent mouseEvent)
Don't Care *- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
- Parameters:
mouseEvent
- The mouse event
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
Don't Care *- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
- Parameters:
mouseEvent
- The mouse event
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
Don't Care *- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
- Parameters:
mouseEvent
- The mouse event
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent mouseEvent)
Don't Care *- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
- Parameters:
mouseEvent
- The mouse event
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent keyEvent)
Don't Care *- Specified by:
keyTyped
in interfacejava.awt.event.KeyListener
- Parameters:
keyEvent
- The key event
-
keyPressed
public void keyPressed(java.awt.event.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 key- Specified by:
keyPressed
in interfacejava.awt.event.KeyListener
- Parameters:
keyEvent
- The key event
-
setCellImageBorder
public void setCellImageBorder(ImageBorder imageBorder)
Sets the image border used to draw around the items in the menu- Parameters:
imageBorder
- The desired image border
-
setCellRenderer
public void setCellRenderer(javax.swing.ListCellRenderer cellRenderer)
Specifies the list cell renderer used to draw the items in the menu- Parameters:
cellRenderer
- The list cell renderer
-
keyReleased
public void keyReleased(java.awt.event.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.- Specified by:
keyReleased
in interfacejava.awt.event.KeyListener
- Parameters:
keyEvent
- The key event
-
mouseWheelMoved
public void mouseWheelMoved(java.awt.event.MouseWheelEvent mouseWheelEvent)
Moves the selected menu up or down when the mouse wheel scrolls- Specified by:
mouseWheelMoved
in interfacejava.awt.event.MouseWheelListener
- Parameters:
mouseWheelEvent
- The mouse wheel event
-
setUpDownIcons
public void setUpDownIcons(javax.swing.Icon upIcon, javax.swing.Icon downIcon)
Sets icons to use to show the up and down buttons- Parameters:
upIcon
- The icon to use for updownIcon
- The icon to use for down
-
setMenuScrollColor
public void setMenuScrollColor(java.awt.Color color)
Allows the background color to the menu (left side) to be set- Parameters:
color
- Sets the background color to the menu
-
-