Class ImageFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class ImageFrame extends JFrame
A simple display widget with an image pane and a status bar that shows the image location and data value(s) of the mouse cursor.

Typical use is:


 ImageFrame frame = new ImageFrame();
 frame.displayImage(imageToLookAt, imageWithData, "My beautiful image");
 
Note: the default close operation for the frame is JFrame.EXIT_ON_CLOSE.
Since:
1.0
Author:
Michael Bedward
See Also:
  • Constructor Details

    • ImageFrame

      public ImageFrame(RenderedImage img, String title)
      Constructor to display and draw data from a single image
      Parameters:
      img - the image to display
      title - title for the frame
    • ImageFrame

      public ImageFrame(RenderedImage displayImg, RenderedImage dataImg, String title)
      Constructor for separate display and data images.
      Parameters:
      displayImg - image to be displayed
      dataImg - an image with bounds equal to, or enclosing, those of displayImg and which contains data that will be reported in the status bar; if null data will be drawn from the display image
      title - title for the frame
  • Method Details

    • showImage

      public static void showImage(RenderedImage img, String title)
      Displays the given image in a new ImageFrame. This method can be safely called from any thread. The frame's closing behaviour will be WindowConstants.EXIT_ON_CLOSE.
      Parameters:
      img - image to display
      title - frame title
    • showImage

      public static void showImage(RenderedImage img, String title, boolean exitOnClose)
      Displays the given image in a new ImageFrame. This method can be safely called from any thread. The frame's closing behaviour will be either WindowConstants.EXIT_ON_CLOSE or WindowConstants.DISPOSE_ON_CLOSE depending on the exitOnClose argument.
      Parameters:
      img - image to display
      title - frame title
      exitOnClose - true for exit on close; false for dispose on close
    • setStatusText

      public void setStatusText(String text)
      Set the status bar contents. This is used by ImagePane
      Parameters:
      text - the text to display