Java swing removes the focus box around the button text, and draws Wing
There is nothing left to worry about. I wrote a swing interface. After running it, I can see that when I click the button, a small box containing the text appears in the middle, which indicates that the button gets the focus, I think it's ugly! How can I remove it? The omnipotent du Niang told me to set the setFocusPainted of the button to false. I tried it and it was OK. I will share the code below, you can note the sentence for setting attributes to see the effect before and after.
Import java. awt. event. actionEvent; import java. awt. event. actionListener; import javax. swing. JButton; import javax. swing. JFrame; public class SwingDemo {public static void main (String [] args) {// method stub automatically generated by TODO JFrame jframe = new JFrame ("Demo "); JButton button = new JButton ("JB"); button. addActionListener (new ActionListener () {@ Override public void actionreceivmed (ActionEvent e) {System. out. println ("click JB") ;}}); // remove the focus box button around the button text. setFocusPainted (false); jframe. getContentPane (). add (button); jframe. setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE); jframe. setBounds (100,100,200,136); jframe. setVisible (true );}}