it is possible to draw directly to the frame, using frame's paint(..) method,
but better to use a JPanel because of its paintComponent(..)
although, in this recent
thread (with example of using JFrame and paint())
https://coderanch.com/t/343029/GUI/java/repaint-method it was suggested paintComponent(..) should be used for the JFrame.
I still can't find a paintComponent() method for a JFrame, so I'll leave it
for you to experiment