It all comes down to how to how image sampling works
When images are taken from the real world (or rendered) they are sampled in pixels. The number of those pixels is called spacial resolution: width*height. So obviously images are always represented as a rectangles, so to make the math easier. Just imagine how much extra work would go into rendering images if they were in radial coordinates for example ;)
But, if its the displaying of the image that you are asking about. Then of course you could display them in whatever shape you like. Look at how whats app displays avatars in a circle for example.
How to realize that in Java?
You will have to create your own JComponent
, most likely a subclass of JLabel
and override the paint
method to suit your needs. Something like
public class MyCircularLabel extends JLabel{
BufferedImage image;
//constructors, setters , getters ...
@Override
paint(Graphics g){
super.paint(g);
//initialize some polygon
//draw the image in the shape you prefer here
}
}
I honestly have never tried something like this. But in general that's what you do when you want the GUI to be drawn in a way that's different than the default : you override paint
Also you might want to look at JavaFx, since its more suited for "stylish" UI than Swing is. Look at this example
Border-Radius and Shadow on ImageView