如何删除按钮单击上的文本框高亮(Java)

时间:2017-06-15 15:21:49

标签: java text jbutton highlight

我所指的重点:

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;
}

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

1 个答案:

答案 0 :(得分:0)

添加此

button.setFocusPainted(false);
相关问题