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

public class ImageLabel extends JLabel
A simple component that scales an image to fit inside the size of the component.
See Also:
  • Field Details

    • imageIcon

      protected ImageIcon imageIcon
      The image that ends up getting scaled
  • Constructor Details

    • ImageLabel

      public ImageLabel(ImageIcon icon)
      Creates a new instance of ImageLabel. The prefered width and height will be set to the dimensions of the image
      Parameters:
      icon - The image to display
    • ImageLabel

      public ImageLabel(ImageIcon icon, int width, int height)
      Creates a new instance of ImageLabel, setting the preferred rendering size to the supplied dimensions
      Parameters:
      icon - The image to place on the label
      width - The prefered width
      height - The prefered height
  • Method Details

    • paintComponent

      public void paintComponent(Graphics graphics)
      Paints the label scaling the image to the appropriate size
      Overrides:
      paintComponent in class JComponent
      Parameters:
      graphics - The graphics context