简体   繁体   中英

JButton setBackground doesn't work

i try to set Background color of jbutton, but doesn't work? Look at image. Why doesnt work? How to fix?

I want red background :-)

在此处输入图片说明

    save_button.setForeground(Color.red);
    save_button.setBackground(Color.red);
    close_button.setForeground(Color.red);
    close_button.setBackground(Color.red);

Add to the code for both buttons :

save_button.setOpaque(true);

It should work, if not try disabling the border color

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM