简体   繁体   中英

How to fill a shape with an ImageIcon in Java swing?

I am trying to fill a shape with an imageIcon and I keep getting an error saying that it should be converted to a paint. I am afraid I don't know how to do it. I have read quite a few examples from different sources but they are not using swing. The code below shows one of the ways I was trying to achieve that. Thanks in advance!

Circle cir2 = new Circle(250,250,120);
cir2.setFill(profileSidebar.getImage());

I keep getting an error saying that it should be converted to a paint.

Maybe you can use a TexturePaint .

According to the API you can use:

 TexturePaint paint = new TexturePaint(BufferedImage, Rectangle);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM