How to make transparent background color of an image that displayed through jxImageview

StackOverflow https://stackoverflow.com/questions/8862626

  •  28-10-2019
  •  | 
  •  

Question

I made a JxImageView object and set an image to it, now i got white color as its background which is not in the original image. i just want to remove the white color from the viewport.

Was it helpful?

Solution

After reading the docs, I conclude (correct me if I am wrong) you can't change the white background

In the Constructor of JxImageView, you see:

/** Creates a new instance of JXImageView */
public JXImageView() {
      checkerPaint = ColorUtil.getCheckerPaint(Color.white,
      new Color(250, 250, 250), 50);
      setEditable(true);
}

and checkerPaint cannot be accessed

OTHER TIPS

I don't know JxImageView, but I don't see how it could change the background color of an image, because an image doesn't have any background color. It probably just means that some parts of the image are transparent, and that the white color you see is the background color of the component which displays the image: JxImageView. You should just probably change the background color of the JxImageView, to the color that suits you.

The JxImageView could also itself be transparent, in which case you would see its parent component's background.

Try loading the image in an image editor to confirm that the image is transparent.

JXImageView bug fixed in the current snapshot (btw, post-SwingX 1.6.3, just in case you missed the release announcement :) To replace the default checkered background, simply set a custom background painter:

JXImageView ipa = new JXImageView();
ipa.setBackgroundPainter(new MattePainter(Color.RED));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top