How to make a circular JFrame if possible?
You can draw a circle and oval using the Graphics. drawOval(int x, int y, int width, int height) method. This function performs both functions. 'x' and 'y' are the starting point on the screen, and 'width' and 'height' are the parameters to set the width and height of the oval or circle.
Essentially what you have to do is make the outer part of your JFrame rendered surface transparent and then draw your own custom shape in the middle.
Circle is just suppose to draw a circle in the frame created by Frame with random starting position (and defind the radius). Frame is the mainclass with methods such as addCircle(), bounce(), start(), stop(), run() (moves the circles) and quit(). This class also creates the frame in which the circles are added to.
Basically, a JFrame represents a framed window and a JPanel represents some area in which controls (e.g., buttons, checkboxes, and textfields) and visuals (e.g., figures, pictures, and even text) can appear.
Oracle has a nice tutorial on exactly this topic: https://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html
Shaped Windows
The other feature introduced in release 6u10 is the window shaping effect. Using shaping you can set any shape to an undecorated window. When the effect is applied, the desired area of a window becomes transparent. Thus, the combination of transparent and non-transparent pixels form the shape of a given window. The next images demonstrate window shaping in two cases:
[Text extracted from original article http://www.oracle.com/technetwork/articles/javase/translucent-shaped-windows-139324.html ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With