Atitit. GUI picture non-rule button and dynamic picture switch implementation Mode summary java. NET C # C + + web HTML JS

Source: Internet
Author: User

Atitit. GUI picture non-rule button and dynamic picture switch Implementation Mode Summary java. NET C # C + + web HTML JS

1. Summary of the effect of the Picture button 1

1.1. Button picture is automatically scaled. 1

1.2. Do not frame, if you use a custom picture to make a button background can be set to false. 2

1.3. Shaped Button 2

1.4. Do not draw focus 2

1.5. Icons when the mouse is over 2

1.6. Icon 2 When selected

1.7. Icons displayed when disabled 2

1.8. Button translucent effect may be required 2

2. Picture Button Implementation 2

2.1. Priority mode : Button control mode +backgroud Property 2

2.2. Next mode 2::lable/img Control Implementation 3

3. Implementation of a non-rule button 3

3.1. Pass through color properties (recommended, convenient) 3

3.2. Clear fill :p ng picture mode 3

3.3. Setmask mode 3

3.4. Redraw the button 's paint event (least recommended, complex) 3

3.5. Html hotspot map mode 3

4. Mouse over the dynamic picture switch implementation 4

4.1. Priority mode :: CSS mode ... 4

4.2. Second Mode 2:: Set the property mode . 4

4.3. Final mode 3:: Write mouse listener 4

5. Implementation of the Translucent button 4

5.1. Property method, convenient. Recommended 4

5.2. Transparent picture Background Method 4

5.3. Background dynamic coordinate method of the control 4

5.4. Dynamic Redraw (Trouble 5

6. Java Detail Button Properties 5

7. Reference 7

1. Summary of the effect of the Picture button 1.1. The button picture is automatically scaled.

The middle walk slightly picture big do not PS adjust blue , convenient ...

1.2. Do not frame, if you use a custom picture to make a button background can be set tofalse. 1.3. Shaped button

Clear blank blanks If your custom picture is not a rectangle or there is a blank margin, you can set false to make the button appear transparent.

1.4. Do not draw focus

1.5. Icon 1.6 When the mouse passes. Icon When selected

1.7. Icon 1.8 to display when disabled. May require a button translucency effect

Author :: Old Wow's paw attilax ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

2. Picture button Implementation 2.1. Priority mode: Buttoncontrol pattern+backgroudProperties

Java Implementation, you can use the button mode

2.2. Second mode2::lable/imgControl Implementation3. Implementation of the Non-rule button 3.1. Penetrate color properties (recommended, convenient)

This color in the picture will not be rendered. Of course, complicated pictures don't fit.

C # supports this implementation

3.2. Transparent fill in the blanks:p ngPicture Mode

Java is png+prop .

3.3. SetmaskMode

C + + qt can use pn,gif images for setmask mode . Ui->pushbutton->setmask (Pixmap.mask ());

3.4. Redraw buttonof thePaintEvents (least recommended, complex)

But this is the ultimate realization, the bottom. General.

3.5. HtmlHot SpotsMapMode

4. Mouse over the dynamic picture switch implementation 4.1. Priority mode:: CSSMode...

C + + qt can use this mode

4.2. Second mode2::Set Property Mode..

Java does not support CSS mode, you can use attribute mode. However, the set of properties is much more, you can extract an extension class.

4.3. The final model3::Write Mouse Listener5. Implementation of the Translucent button 5.1. Attribute method, convenient. Recommended

C + + qt SetAttribute (Qt::wa_translucentbackground, true);

5.2. Transparent picture background method 5.3. The background dynamic coordinate method of the control

Without this function ... The background root of the control can only be
According to the plugin's coordinates, set the same as the window background
That is, if the control is at the X1,y1 point, the background image used is also set to the x1,y1 's coordinates when the control is set to the background in the control's actual position.




The so-called control is transparent, and the background of the accusation piece is the same as the large background of the window.


If the control does not move, you can take the background of the corresponding position in the window to make the background of the control, with Setbackgroudpixmap


If the control is movable, it is necessary to re-set the background of the background of the window when it is moved.


The principle is so that you can achieve it yourself.

5.4. Dynamic Redraw (trouble

6. JavaDetail Button Properties

JButton implementation of the normal three-state plus check, disabled state, there are many ways to set, do not write your own mouse listener. With these methods there is no need to draw a button yourself or use a mouse listener.

Setborderpainted (BOOLEAN B)//whether to draw a border, if you use a custom picture to make a button background can be set to  false.  setcontentareafilled (BOOLEAN B)//is filled, if your custom picture is not a rectangle or there is a blank margin, you can set it to  false  make the button appear transparent.  setfocuspainted (BOOLEAN B)//Whether the focus is drawn (for example, a light dashed box or a bold border indicates that the button currently has focus).

SetMargin (Insets m)//change the margin, if both borderpainted and contentareafilled are set to False, it is recommended that the margin be adjusted to 0:new Insets (0, 0, 0, 0). SetIcon (icon DefaultIcon)//Note This is the default icon for the change. The default in three states, that is, when the mouse is not on it. Setpressedicon (icon Pressedicon)//when pressed. Setrollovericon (icon Rollovericon)//icons when the mouse passes. Icon for Setrolloverselectedicon (icon Rolloverselectedicon)//mouse over and selected. Setselectedicon (icon Selectedicon)//icons When selected. Setdisabledicon (icon Disabledicon)//icons displayed when disabled. For example, you can change a grayscale image. Setdisabledselectedicon (icon Disabledselectedicon)//disabled and selected icons. --------------------------------------------How big the button, remove the margin after the picture is how big. is automatically scaled. So if margin is set to 0, the size of the button is how big the picture is. With these methods there is no need to draw a button yourself or use a mouse listener.

7. Reference

Paip. Enhancing the User experience---C + + Qpushbutton button controls transparent and irregular buttons as well as mouse over dynamic settings-attilax column-Blog channel-CSDN.NET.htm

Paip. Improving the user experience---control transparency settings-Attilax's column-Blog channel-CSDN.NET.htm

Atitit. GUI picture non-rule button and dynamic picture switch implementation Mode summary java. NET C # C + + web HTML JS

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.