Is it possible to draw a circle without the class being a child of JPanel?
Kind, but this was due to problems. I will try to explain
If you want to do custom paint in Swing, you must override the paintComponent method of any component that extends from JComponent , JPanel is usually the easiest solution, since working with pictures
See Painting in AWT and Swing and Performing Custom Painting for more details on how painting works.
Generally speaking, it is impractical to try to draw directly into a top-level container, such as a JFrame , since it contains a number of other child components that are drawn on top of it ( JRootPane , contentPane , glassPane , menuBar , etc.) that can be painted regardless of the frame. cause some strange artifacts of painting.
A more detailed idea of ββwhat a JFrame looks JFrame ...

JFrame also not a double buffer, which means that if you try to draw it directly, trying to quickly update it, it will cause flickering. JComponent , and its decients are duplicated by default
Swing itself uses a passive rendering mechanism, which means that you actually do not control the drawing process, you are simply notified when your component should be painted (using the paintComponent method). Swing can choose to draw child components without having to notify the parent container, which is one of the reasons paintComponent recommended. It can also combine multiple paint requests with as few calls as possible to optimize the process.
All this is done without your knowledge or control.
If you want more control over the drawing process, you can consider using BufferStrategy , which gives you direct (double buffered) control of the drawing process, so you can decide when and what should be painted. But even this will require you to use java.awt.Canvas as a base with which you can create your own output.
As a rule, it is usually not recommended to spread from JFrame (or most top-level containers) and instead use one of the container classes as the base class. This way you get much more freedom about how they should be displayed or reused, adding them to what has ever been another container.