简体   繁体   中英

How to crop an image into circle in java?

I am working on a small Inventory System for my university project, I am planning that admin should be able to change the system logo.

The problem is when admin changes the photo, it will be displayed as original size and shape and the whole look get ugly so here is my question.

How can I crop the image into a circle and 250 x 250 pixel?

PS When I first asked this question, I just started learning Java and my English language was not good; so here I am 4 and a half years letter editing my own question completely.

A label is transparent by default.

So either you have non-transparent pixels in your image or the frame itself is not transparent so you see the frame background.

Read the section from the Swing tutorial on How to Create Translucent and Shaped Windows for more information on transparent frames.

Basiclly you need to use a non decorated frame and then use:

frame.setOpacity(0.0);

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