如何设置JButton的颜色?
我尝试了以下方法:
button.setBackground(Color.red);
但是没有成功。这只改变了按钮边框的颜色。我接着尝试重写
paintComponents
函数。public void paintComponent(Graphics g) {
g.setColor(Color.GREEN);
g.fillRect(0, 0, getSize().width, getSize().height);
}
但是现在我看不到JButton上的文本。