ComponentListener
, KeyListener
, MouseListener
, MouseWheelListener
, ImageObserver
, MenuContainer
, Serializable
, EventListener
, Accessible
, ChangeListener
, ListSelectionListener
public class JCarouselMenu extends GradientPanel implements ListSelectionListener, MouseListener, KeyListener, ChangeListener, MouseWheelListener
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 selected
|
class |
JCarouselMenu.MenuItem |
A menu item inside the carousel
|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Container.AccessibleAWTContainer
JComponent.AccessibleJComponent
JPanel.AccessibleJPanel
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
cache, end, gp, start
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor | Description |
---|---|
JCarouselMenu() |
Creates a new instance
|
JCarouselMenu(ImageBorder border) |
Creates a new instance of JCarouselMenu
|
Modifier and Type | Method | Description |
---|---|---|
Component |
add(Component component,
String label) |
Adds a component to the carousel menu that will be brought into view when the user clicks
on the associated item
|
Component |
add(Image image,
String label) |
Adds an image (with a label) and returns the component created to represent them
|
Component |
add(Image image,
String label,
int width,
int height) |
Deprecated.
Use add(Image, String) instead
|
Component |
add(String imageURL,
String label) |
Adds an image based on the imageURL and a text label, returning the component that is created as a result
|
Component |
add(String imageURL,
String label,
int width,
int height) |
Deprecated.
Use add(imageURL, label) instead
|
Component |
add(Action action) |
Adds an action to the list, creating a menu item and a carousel entry
|
Component |
add(Action action,
int width,
int height) |
Deprecated.
Use add(imageURL) instead
|
JList |
getList() |
Returns the list part of the carousel menu
|
Dimension |
getPreferredSize() |
Return the preferred size of the component
|
void |
keyPressed(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
|
void |
keyReleased(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(KeyEvent keyEvent) |
Don't Care *
|
void |
mouseClicked(MouseEvent mouseEvent) |
Look to see if an item in the list is double clicked, and launch the action if it is
|
void |
mouseEntered(MouseEvent mouseEvent) |
Don't Care *
|
void |
mouseExited(MouseEvent mouseEvent) |
Don't Care *
|
void |
mousePressed(MouseEvent mouseEvent) |
Don't Care *
|
void |
mouseReleased(MouseEvent mouseEvent) |
Don't Care *
|
void |
mouseWheelMoved(MouseWheelEvent mouseWheelEvent) |
Moves the selected menu up or down when the mouse wheel scrolls
|
protected void |
processAction() |
Launch the action associated with the currently selected list item
|
void |
remove(Component component) |
Removes a component from the menu
|
void |
setCellImageBorder(ImageBorder imageBorder) |
Sets the image border used to draw around the items in the menu
|
void |
setCellRenderer(ListCellRenderer cellRenderer) |
Specifies the list cell renderer used to draw the items in the menu
|
void |
setMenuScrollColor(Color color) |
Allows the background color to the menu (left side) to be set
|
void |
setSelectedIndex(int i) |
Sets the selected item in the menu
|
void |
setUpDownColor(Color color) |
Sets the color the up and down buttons are drawn
|
void |
setUpDownIcons(Icon upIcon,
Icon downIcon) |
Sets icons to use to show the up and down buttons
|
void |
stateChanged(ChangeEvent e) |
Detect when the list selection changes, and respond by updating the state
of the two "arrow" buttons.
|
void |
valueChanged(ListSelectionEvent listSelectionEvent) |
Detect when the list selection changes, and respond by rotating the carousel to show
that item
|
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
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
componentHidden, componentMoved, componentResized, componentShown, paintComponent, setBackground, setBackground
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
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
public JCarouselMenu(ImageBorder border)
border
- The border to use to draw items in the menupublic JCarouselMenu()
public void setUpDownColor(Color color)
color
- The desired colorpublic JList getList()
public void setSelectedIndex(int i)
i
- The index of the item to selectpublic Component add(Component component, String label)
component
- The componentlabel
- The text to appear in the menupublic void remove(Component component)
public Component add(Image image, String label, int width, int height)
image
- The imagelabel
- The textwidth
- Prefered widthheight
- Prefered heightpublic Component add(Image image, String label)
image
- The image to displaylabel
- The label to showpublic Component add(Action action, int width, int height)
action
- The action to addwidth
- The widthheight
- The heightpublic Component add(Action action)
action
- The action to addpublic Component add(String imageURL, String label, int width, int height)
imageURL
- URL of the imagelabel
- Text messagewidth
- widthheight
- heightpublic Component add(String imageURL, String label)
imageURL
- The URL of the imagelabel
- Text label to be shown in the menupublic Dimension getPreferredSize()
getPreferredSize
in class JComponent
public void stateChanged(ChangeEvent e)
stateChanged
in interface ChangeListener
e
- The state changed eventChangeListener.stateChanged(javax.swing.event.ChangeEvent)
public void valueChanged(ListSelectionEvent listSelectionEvent)
valueChanged
in interface ListSelectionListener
listSelectionEvent
- The list selection change eventprotected void processAction()
public void mouseClicked(MouseEvent mouseEvent)
mouseClicked
in interface MouseListener
mouseEvent
- The mouse eventpublic void mousePressed(MouseEvent mouseEvent)
mousePressed
in interface MouseListener
mouseEvent
- The mouse eventpublic void mouseReleased(MouseEvent mouseEvent)
mouseReleased
in interface MouseListener
mouseEvent
- The mouse eventpublic void mouseEntered(MouseEvent mouseEvent)
mouseEntered
in interface MouseListener
mouseEvent
- The mouse eventpublic void mouseExited(MouseEvent mouseEvent)
mouseExited
in interface MouseListener
mouseEvent
- The mouse eventpublic void keyTyped(KeyEvent keyEvent)
keyTyped
in interface KeyListener
keyEvent
- The key eventpublic void keyPressed(KeyEvent keyEvent)
keyPressed
in interface KeyListener
keyEvent
- The key eventpublic void setCellImageBorder(ImageBorder imageBorder)
imageBorder
- The desired image borderpublic void setCellRenderer(ListCellRenderer cellRenderer)
cellRenderer
- The list cell rendererpublic void keyReleased(KeyEvent keyEvent)
keyReleased
in interface KeyListener
keyEvent
- The key eventpublic void mouseWheelMoved(MouseWheelEvent mouseWheelEvent)
mouseWheelMoved
in interface MouseWheelListener
mouseWheelEvent
- The mouse wheel eventpublic void setUpDownIcons(Icon upIcon, Icon downIcon)
upIcon
- The icon to use for updownIcon
- The icon to use for downpublic void setMenuScrollColor(Color color)
color
- Sets the background color to the menu