Quoting from documentation of paint()
method
This method actually delegates the work of painting to three protected methods: paintComponent, paintBorder, and paintChildren.
…
A subclass that just wants to specialize the UI (look and feel) delegate’s paint method should just override paintComponent.
It looks like the paint()
method actually draws the component, including the border and children. If you only want to customize the component’s appearance excluding the border and children, you use paintComponent()
.
http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#paint(java.awt.Graphics)