Search This Blog

Showing posts with label Change shape. Show all posts
Showing posts with label Change shape. Show all posts

How to Change Shape of JFrame - Rounded Rectangle, Circle, Ellipse etc

You can change the shape of the JFrame. By default its shape is rectangular and assumes the size set using setSize() method. In this post we will discuss how to change the shape of  JFrame. You can change JFrame's shape into rounded rectagle, cirlce, ellipse, etc. We will see how to set the shape of JFrame with java code sample and screenshots. To change the shape of JFrame to any shape, we use the setShape() method.

Prerequisites

There are some prerequisites for setting or changing the shape of JFrame. They are:
The Frame should be undecorated. You should call the setUndecorated(true) method before calling setShape() method. When you set the frame undecorated, you will lose the title-bar,close button, maximise and minimise buttons. So you will have to create these button syourself.