Class JXImagePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, AlphaPaintable, BackgroundPaintable

@Deprecated class JXImagePanel extends JXPanel
Deprecated.
(pre-1.6.2) use a JXPanel with an ImagePainter; see Issue 988

A panel that draws an image. The standard mode is to draw the specified image centered and unscaled. The component&s preferred size is based on the image, unless explicitly set by the user.

Images to be displayed can be set based on URL, Image, etc. This is accomplished by passing in an image loader.

 public class URLImageLoader extends Callable<Image> {
     private URL url;
 
     public URLImageLoader(URL url) {
         url.getClass(); //null check
         this.url = url;
     }
 
     public Image call() throws Exception {
         return ImageIO.read(url);
     }
 }
 
 imagePanel.setImageLoader(new URLImageLoader(url));
 

This component also supports allowing the user to set the image. If the JXImagePanel is editable, then when the user clicks on the JXImagePanel a FileChooser is shown allowing the user to pick some other image to use within the JXImagePanel.

TODO In the future, the JXImagePanel will also support tiling of images, scaling, resizing, cropping, segues etc.

TODO other than the image loading this component can be replicated by a JXPanel with the appropriate Painter. What's the point?

  • Field Details

    • LOG

      private static final Logger LOG
      Deprecated.
    • TEXT

      private static final String TEXT
      Deprecated.
      Text informing the user that clicking on this component will allow them to set the image
      See Also:
    • img

      private SoftReference<Image> img
      Deprecated.
      The image to draw
    • editable

      private boolean editable
      Deprecated.
      If true, then the image can be changed. Perhaps a better name is "readOnly", but editable was chosen to be more consistent with other Swing components.
    • mhandler

      private JXImagePanel.MouseHandler mhandler
      Deprecated.
      The mouse handler that is used if the component is editable
    • style

      private JXImagePanel.Style style
      Deprecated.
      Specifies how to draw the image, i.e. what kind of Style to use when drawing
    • defaultImage

      private Image defaultImage
      Deprecated.
    • imageLoader

      private Callable<Image> imageLoader
      Deprecated.
    • service

      private static final ExecutorService service
      Deprecated.
  • Constructor Details

    • JXImagePanel

      public JXImagePanel()
      Deprecated.
    • JXImagePanel

      public JXImagePanel(URL imageUrl)
      Deprecated.
  • Method Details

    • setImage

      public void setImage(Image image)
      Deprecated.
      Sets the image to use for the background of this panel. This image is painted whether the panel is opaque or translucent.
      Parameters:
      image - if null, clears the image. Otherwise, this will set the image to be painted. If the preferred size has not been explicitly set, then the image dimensions will alter the preferred size of the panel.
    • getImage

      public Image getImage()
      Deprecated.
      Returns:
      the image used for painting the background of this panel
    • setEditable

      public void setEditable(boolean editable)
      Deprecated.
      Parameters:
      editable -
    • isEditable

      public boolean isEditable()
      Deprecated.
      Returns:
      whether the image for this panel can be changed or not via the UI. setImage may still be called, even if isEditable returns false.
    • setStyle

      public void setStyle(JXImagePanel.Style s)
      Deprecated.
      Sets what style to use when painting the image
      Parameters:
      s -
    • getStyle

      public JXImagePanel.Style getStyle()
      Deprecated.
      Returns:
      the Style used for drawing the image (CENTERED, TILED, etc).
    • getPreferredSize

      public Dimension getPreferredSize()
      Deprecated.
      The old property value in PCE fired by this method might not be always correct!
      Overrides:
      getPreferredSize in class JComponent
    • paintComponent

      protected void paintComponent(Graphics g)
      Deprecated.
      Overridden to paint the image on the panel
      Overrides:
      paintComponent in class JXPanel
      Parameters:
      g -
    • setDefaultImage

      public void setDefaultImage(Image def)
      Deprecated.
    • setImageLoader

      public void setImageLoader(Callable<Image> loadImage)
      Deprecated.