Swing custom crystal button

Source: Internet
Author: User

Custom crystal button like win7

Download complete projectHttp://download.csdn.net/detail/jasper_success/4488514

KeyCode

Public void paintcomponent (Graphics g) {graphics2d g2 = (graphics2d) g; alphacomposite composite = alphacomposite. getinstance (alphacomposite. src_over, alpha); g2.setcomposite (composite); // draw the border if (this. ismouseentered) {util. drawbuttonbackground (G2, this, new color (253,236,219), new color (253,223,187), new color (255,206,105), new color (255,255,222 ));} // Effect of Button being pressed if (clicked) {util. drawbuttonbackg Round (G2, this, new color (255,199, 99), new color (253,236,219), new color (253,236,219, 99);} composite = alphacomposite. getinstance (alphacomposite. src_over, 1f); g2.setcomposite (composite); If (frametype = frame_around) {G. setcolor (config. color_toolbar_frame); G. drawroundrect (1, 1, getwidth ()-4, getheight ()-2, 3, 3);} else if (frametype = frame_right) {G. setcolor (config. Color_toolbar_frame); G. drawline (getwidth ()-1, 1, getwidth ()-1, getheight ()-2);} // eliminate the Sawtooth util. setfractionalmetricson (G2); // text style G. setcolor (config. color_ui_text); G. setfont (config. font_ui_text); // draw the icon if (getimage ()! = NULL) {G. drawimage (getimage (), (getwidth ()-getimage (). getwidth (this)/2, 5 + mbstatus, this); G. drawstring (getname (), (getwidth ()-getname (). length () * config. font_ui_text.getsize ()/2, getimage (). getheight (this) + mbstatus);} else {G. drawstring (getname (), (getwidth ()-getname (). length () * config. font_ui_text.getsize ()/2, 10 + mbstatus );}}

Download http://download.csdn.net/detail/jasper_success/4488514

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.