Drawing should be done on a JPanel (or other JComponent). Refer to the Custom Painting tutorial.