The difference between paint () and paintcomponent () in swing

Source: Internet
Author: User

Excerpt from the Internet.

1- Paint() call Paintcomponent (), Paintborder (), Paintchildren ()

2-The most important difference is "double buffering". Swing component of the paint() to achieve double buffering, so do not go to overwrite, will break the double buffering, ———— suggested way is to overwrite paintcomponent (), many people do the small program will "blink", It is because they overwrite the paint() method, which destroys the double buffering of Swing itself. Swing does not recommend that users implement double buffering themselves.

3-Overwrite paint(), if the new method does not call Paintchildren (), but also cause the child control does not display, the mouse moved up to display, this is also a lot of novice asked questions: "Why my button only mouse up to display?" ”

4-Only a very small number of cases may need to overwrite the paint() method, usually to achieve special drawing effects, or special optimizations such as JViewport overwrite the paint() method, using "delay redraw" The way to merge some particularly frequent redraw requests when the scroll bar moves, and so on.

The difference between paint () and paintcomponent () in swing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.