我尝试设置 jbutton 的背景颜色,但不起作用?看图片。为什么不起作用?如何修复?
我想要红色背景:-)
save_button.setForeground(Color.red);
save_button.setBackground(Color.red);
close_button.setForeground(Color.red);
close_button.setBackground(Color.red);
最佳答案
添加到两个按钮的代码:
save_button.setOpaque(true);
它应该可以工作,如果不行尝试禁用边框颜色
关于java - JButton setBackground 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18430620/