Swinghacks -- button blur effect

Source: Internet
Author: User

Take a picture first. The normal image is as follows:

After the buttons are disable, The comparison results are as follows:

The following normal is the effect after the normal button disable

The above is the blur effect.

Let's take a look at the principle. The idea is to rewrite paintcomponent, and then use paintcomponent (BUF. getgraphics) to obtain the image of the original control style.

Blur the image and draw it out to read the code.

Public void paintcomponent (Graphics g) {If (isenabled () {// the original style super is returned here. paintcomponent (g); return;} // definition matrix float [] my_kernel = {0.10f, 0.10f, 0.10f, 0.10f, 0.20f, 0.10f, 0.10f, 0.10f, 0.10f, 0.10f }; convolveop op = new convolveop (new kernel (3, 3, my_kernel); bufferedimage Buf = new bufferedimage (getwidth (), getheight (), bufferedimage. type_int_rgb); // draw the control to the Buf image first. paintcomponent (BUF. getgraphics (); // perform the fuzzy filtering algorithm image IMG = op. filter (BUF, null); // draw the processed button G. drawimage (IMG, 0, 0, null );}

This method can blur various controls, such as blurring the background after a button is clicked, and a time Wait window pops up.

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.