Module video

Class ImagePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ImagePanel extends JPanel
Small class to display images in a panel with a fixed size. Images can be drawn using the draw(Image) method. The clear() method will clear the image displaying area.
Author:
Dominick Leppich
See Also:
  • Field Details

    • BORDER_WIDTH

      public static final int BORDER_WIDTH
    • BORDER_HEIGHT

      public static final int BORDER_HEIGHT
      See Also:
    • BORDER_SIZE

      public static final int BORDER_SIZE
      See Also:
  • Constructor Details

    • ImagePanel

      public ImagePanel(int width, int height)
      Create a new ImagePanel which displays an image with the given size.
      Parameters:
      width - - Width of the image to display
      height - - Height of the image to display
  • Method Details

    • draw

      public void draw(Image img, int current, int max)
      Draws an image in the ImagePanel component. Bigger images will be down scaled, smaller ones will be displayed in the center.
      Parameters:
      img - - Image to draw
    • clear

      public void clear()
      Clears the ImagePanel displaying area with a black color.
    • setBorder

      public void setBorder(boolean value)
      Enable or disable border
      Parameters:
      value - - Value
    • paintComponent

      public void paintComponent(Graphics g)
      Draw the image on the panel using the Graphics context. Additionally draw preview borders, title or a progress bar.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - - Graphics context