What is the actual difference between paint(), paintComponent() and paintComponents() in Java Swing?
I tried to understand what explained in Oracle docs but I am not clear.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
paint().JFrame,JWindow,JDialog,JApplet..), overridepaint(). But there are a number of good reasons not to paint in a TLC. A subject for a separate question, perhaps.JComponent), overridepaintComponent().paintComponents(), leave it to the API to call it when needed.Be sure to also use
@Overridenotation whenever overriding a method.Doing so would hint at the problem of trying to override
paintComponent(..)in aJFrame(it has no such method), which is quite common to see.