Paint, repaint, validate, update, and updateUI in Swing

Source: Internet
Author: User

Paint ()-this method holds instructions to paint this component. actually, in Swing, you should change paintComponent () instead of paint (), as paint CILS paintBorder (), paintComponent () and paintChildren (). you shouldn't call this method directly, you shoshould call repaint () instead.

Repaint ()-this method can't be overridden. it controls the update ()-> paint () cycle. you shocould call this method to get a component to repaint itself. if you have done anything to change the look of the component, but not it's size (like changing color, animating, etc .) then call this method.

Validate ()-This tells the component to lay itself out again and repaint itself. if you have done anything to change the size of the component or any of it's children (adding, removing, resizing children), you shocould call this method... I think that calling revalidate () is preferred to calling validate () in Swing, though...

Update ()-This method is in charge of clearing the component and calling paint (). again, you shocould call repaint () instead of calling this method directly... if you need to do fast updates in animation you shoshould override this method to just call the paint () method.

UpdateUI ()-Call this method if you have changed the pluggable look & feel for a component after it has been made visible.

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.