JButton Common settings in Java

Source: Internet
Author: User

1, the JButton size of the setting button.setpreferredsize (New Dimension (30,30)); //(30,30) is the size of the button you want to set 2. Transparent setting for JButtonbutton.setcontentareafilled (false);3. Set the border of the button to remove the JButtonbutton.setborderpainted (false);4, the setting of JButton add iconinstantiate an Icon object imageicon image = new ImageIcon (Icons[i]), instantiates a button object, and the Settings button displays a picture of JButton buttons = new JButton (image); --or Button.seticon (new ImageIcon (GetClass () getresource ("Qq.png"));  //qq.png is the picture you want to add5. Make the button change with the pattern on the button Butten.setmargin (New Insets (0,0,0,0)); 6, set up the convex button, many other swing can also use this methodButten.setborder (Borderfactory.createraisedbevelborder ()); 7, set the concave button, many other swing can also use this method        button.setborder ( Borderfactory.createloweredbevelborder ()); 8, set the foreground and background color of the button       button. SetFont (New Java.awt.Font ("XXFarEastFont-Xingkai", 1, 15));       button.setbackground (Color.green); 9, change the style of the button        Uimanager.setlookandfeel ("Com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

JButton Common settings in Java

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.