Class JCarouselMenu.CarouselListCellRenderer

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
org.pushingpixels.lafwidget.contrib.blogofbug.swing.components.JCarouselMenu.CarouselListCellRenderer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ListCellRenderer, SwingConstants
Enclosing class:
JCarouselMenu

protected class JCarouselMenu.CarouselListCellRenderer extends JLabel implements ListCellRenderer
ListCellRenderer for the Carousel uses an image border to draw a nice border around the menu item when it is selected
See Also:
  • Constructor Details

    • CarouselListCellRenderer

      public CarouselListCellRenderer(ImageBorder border)
      Creates a new list cell renderer for the menu with the specified image border
      Parameters:
      border - The border to use
  • Method Details

    • setImageBorder

      public void setImageBorder(ImageBorder border)
      Allows the setting of the image border
      Parameters:
      border - The border to use
    • getListCellRendererComponent

      public Component getListCellRendererComponent(JList jList, Object object, int i, boolean isSelected, boolean cellHasFocus)
      Sets up the component for stamping
      Specified by:
      getListCellRendererComponent in interface ListCellRenderer
      Parameters:
      jList - The list
      object - The object being drawn
      i - The index of the object
      isSelected - If the object is selected
      cellHasFocus - Does the cell have the focus
      Returns:
      The object to use to stamp the list item
    • paintComponent

      public void paintComponent(Graphics g)
      Our image border can paint a center as well as a surround. Call paint center if we want it to do this.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - The graphcis context
    • getPreferredSize

      public Dimension getPreferredSize()
      I want it to be wider than it needs to be
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      The desired width of the cell