Class SelectedImagePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class SelectedImagePanel extends JPanel
An SelectedImagePanel is a JPanel that shows a selected image.
See Also:
  • Constructor Details

    • SelectedImagePanel

      protected SelectedImagePanel(File f)
      Creates new SelectedImagePanel showing the given File name.
      Parameters:
      f - the File to be shown.
    • SelectedImagePanel

      protected SelectedImagePanel(ReadableImage importedImage) throws InvalidImageException, IOException
      Creates new SelectedImagePanel showing the given ReadableImage.
      Parameters:
      importedImage - the ReadableImage to be shown.
      Throws:
      InvalidImageException - if the image is invalid in some way.
      IOException - if an I/O error occurs while copying the supplied image.
  • Method Details

    • getReadableImage

      public ReadableImage getReadableImage() throws InvalidImageException, IOException
      Returns the ReadableImage set in this SelectedImagePanel.
      Returns:
      the ReadableImage set in this SelectedImagePanel.
      Throws:
      InvalidImageException - if the SelectedImagePanel does not yield an valid ReadableImage.
      IOException - if an I/O error occurs while reading the selected image.
    • getImageName

      public String getImageName() throws InvalidImageException
      Returns name of the ReadableImage set in this SelectedImagePanel.
      Returns:
      the name of the ReadableImage set in this SelectedImagePanel.
      Throws:
      InvalidImageException - if the name cannot be retrieved.
    • setToolTipText

      public void setToolTipText(String text)
      Sets the tool tip text for the file selection text field. By default this tool tip is "Shows the current image name - edit to select a new image".
      Overrides:
      setToolTipText in class JComponent
      Parameters:
      text - the tool tip text for the file selection text field.
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides the default getPreferredSize() method. We don't want the SelectedImagePanel to have a different preferred size, for example, when files with long names are selected and the Frame in which this component is embedded is packed(). Once the initial size has been set (and is non-zero), then this component will always have the same preferred size.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      the preferred size of the component.
    • toString

      public String toString()
      Overrides:
      toString in class Component