can please anyone explain the difference between JPanel.repaint() method and JFrame.repaint() method, i guess both calls the paintComponent() method in JPanel.
Please clarify, thanks
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.
Calling
repaint()on any Component will add a request to the repaint manager to paint that component. If conditions are correct, the manager will then arrange to have the Component’spaint(...)method called. Since a Component’s paint method will then callpaintComponent(...),paintBorder(...)andpaintChildren(...)this will have the component paint itself, its border and cascade painting recursively to all of its children, their children, their children’s children, etc. Calling this on JFrame will cause this cascade to occur throughout the entire top-level window whereas calling it on a subcomponent will cause a repainting of that component and its children only.Note that calling
repaint()does not guarantee that the repaint manager will paint the component, especially if there are stacked requests. For more on the details, please read Painting in AWT and Swing.