2017-06-15 23 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

感謝您的幫助小夥子;) –