Originally posted by Ernest Friedman-Hill:
Close, although really not the best solution. You shouldn't override paint(), but rather paintComponent(); and when you do, you should call super.paintComponent() first. Overriding paint() in a Swing component just makes a mess of things.