Common JButton settings in Java, javajbutton
1. Set the JButton size. setPreferredSize (new Dimension (30, 30); // (30, 30) is the size of the button you want to set 2. Set the button transparent to the JButton. setContentAreaFilled (false); 3. Set the button for removing the border of the JButton. setBorderPainted (false); 4. Add an icon to the JButton. instantiate an icon object ImageIcon image = new ImageIcon (icons [I]) and instantiate a button object, and the set button shows the image JButton = new JButton (image); -- or button. setIcon (new ImageIcon (getClass (). getResource ("qq.png"); // qq.png is the image you want to add. 5. Let the button change with the pattern on the button. setMargin (new Insets (,); 6. Set the highlighted button. Many other swing methods can also be butten. setBorder (BorderFactory. createRaisedBevelBorder (); 7. You can use this method to set the concave button. setBorder (BorderFactory. createLoweredBevelBorder (); 8. Set the foreground color and background color of the button. setFont (new java. awt. font (" 文 ", 1, 15); button. setBackground (Color. green); 9. Change the style of the button UIManager. setLookAndFeel ("com. sun. java. swing. plaf. windows. windowsLookAndFeel ");