For java JButton style settings (some functions we should know), javajbutton

Source: Internet
Author: User

Java JButton style settings (some functions we should know) (to), javajbutton

1. Set JButton size 2 -- Because JButen belongs to the small device type, the general setSize cannot be set to the size of the device, so we generally use 3 buttons. setPreferredSize (new Dimension (30, 30); 4 // (30, 30) is the size of the button you want to set 5 2. Set 6 transparent to JButton -- set the button to transparent, in this way, the background 7 button will not be blocked. setContentAreaFilled (false ); 8. Set the border of the Remove button on the JButton 9. If your button does not need a border, the border may affect the appearance or you need to click the button to display the normal figure 10 format, after clicking the button, you can use this method to remove the border 11 button. setBorderPainted (false); 12 4. Set the Add icon to JButton 13 -- // instantiate an icon object 14 ImageIcon image = new ImageIcon (icons [I]); 15 // instantiate the button object, and the setting button displays the image 16 JButton button = new JButton (image); 17 -- or 18 button. setIcon (new ImageIcon (getClass (). getResource ("qq.png"); 19 // qq.png is the image you want to add 20 5. Let the button change with the pattern on the button 21 butten. setMargin (new Insets (,); 22 6. Set the highlighted button. Many other swing methods can also be used 23 butten. setBorder (BorderFactory. createRaisedBevelBorder (); 24 7. Set the concave button. Many other swing methods can also use this method 25 button. setBorder (BorderFactory. createLoweredBevelBorder (); 26 8. Set the foreground color and background color of the button 27 button. setFont (new java. awt. font (" 文 ", 1, 15); 28 button. setBackground (Color. green); 29 9. Change the button style 30 UIManager. setLookAndFeel ("com. sun. java. swing. plaf. windows. windowsLookAndFeel ");

 


How does java JButton set the button style as not pressed? Or JButton cannot be set like this at all?

SetEnabled (false );

In this method, you can set a button failure.
I don't know if it can achieve what you want.

How can I set all jbuttons to a uniform style in java swing?

Refer to the example of the crystal button in Swing Hacks Chinese edition to write a subclass of JButton.
 

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.