2017-06-15 30 views
0

的亮点,我敢闯民宅删除文本框亮点:如何在点击按钮(JAVA)

enter image description here

当我将JButton单击使用下面的代码:

public static JButton addButton(JPanel panel, String text, Point pos, int width, int height, ActionListener action) 
{ 
    JButton button = new JButton(text); 
    button.setBounds(pos.x, pos.y, width, height); 
    button.addActionListener(action); 
    button.setVisible(true); 
    button.setBackground(new Color(255, 137, 58)); 
    button.setForeground(Color.white); 
    button.setBorder(new LineBorder(new Color(196, 96, 29), 2)); 
    button.setRolloverEnabled(true); 
    panel.add(button, 3, 0); 

    return button; 
} 

该文本框之后突出显示。有没有简单的方法来消除这种影响?

回答

0

添加此

button.setFocusPainted(false); 
+0

您可以加入一些解释,它是如何去帮助 – Blip

+0

文档 https://docs.oracle.com/javase/7/docs/api/javax/swing/ AbstractButton.html#setFocusPainted(boolean) –

+0

感谢您的帮助小伙子;) –