如何在单击按钮时删除文本框突出显示 (Java)
How to remove textbox highlight on button click (Java)
我指的亮点:
当我单击使用以下代码的 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;
}
文本框随后突出显示。有没有简单的方法可以消除这种影响?
添加这个
button.setFocusPainted(false);
我指的亮点:
当我单击使用以下代码的 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;
}
文本框随后突出显示。有没有简单的方法可以消除这种影响?
添加这个
button.setFocusPainted(false);