gpt4 book ai didi

java - JButton setBackground 不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 07:26:45 26 4
gpt4 key购买 nike

我尝试设置 jbutton 的背景颜色,但不起作用?看图片。为什么不起作用?如何修复?

我想要红色背景:-)

enter image description here

    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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com