0

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?

P.S. 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.

  • 1
    Unclear what your problem is, do you mean you get a white border around your image? Can you also please post the image (link to it) as well as as your code. If you are unable to share that specific image can you show us an example image instead? – Emz Aug 11 '15 at 14:50
  • For such a thing on uses an **undecorated JFrame**, so without borders. It may contain a transparent JPanel normally, that paints an image with transparency. For instance using a JLabel. – Joop Eggen Aug 11 '15 at 15:17
  • Here Is The Image: [link](http://https://onedrive.live.com/redir?resid=7F7097D87A234BF4!264&authkey=!AEe--BD8K0Mnsqg&v=3&ithint=photo%2cjpg) – Omid Javedan Aug 11 '15 at 18:22
  • 1
    Please refrain from putting 'every other word' starting with upper case. Instead use an upper case letter at the start of sentences, for the word I, and proper names like `ArrayList` or Oracle. – Andrew Thompson Aug 12 '15 at 01:23
  • 1
    What is shown above, is simply an image with a transparent BG to fill out the rest of the square/rectangular shape that it actually is. The 'transparent' part probably means it is a GIF or PNG (JPEG does not support transparency. You can see a number of similar images in [this Q&A](http://stackoverflow.com/q/19209650/418556). – Andrew Thompson Aug 12 '15 at 01:28
  • Here is my problem, when we add a profile picture in Twitter your picture well auto fit to circle, how I do that in Java? Tnx. – Omid Javedan Aug 12 '15 at 14:41
  • @OmidJavedan, *so here I am 4 and a half years letter editing my own question completely.* - well you should NOT be completely editing your question. None of the current comments/answers will make any sense. The question should be restored to its original state. A new question should be asked (if you actually want people to see the question). – camickr Nov 10 '19 at 19:48

1 Answers1

2

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);
camickr
  • 321,443
  • 19
  • 166
  • 288
  • Here is my problem, when we add a profile picture in Twitter your picture well auto fit to circle, how I do that in Java? Tnx. – Omid Javedan Aug 12 '15 at 11:23