I am trying to make it so that the button will change color whenever it is selected. I tried using an if statement to see if the button is selected, and if it is, it will set it to red. However it doesn't work.
if(jToggleButton1.isSelected()) {
jToggleButton1.setBackground(Color.RED);
}
If anyone can describe to me how to make me work that would be much appreciated.
you have to rerender your button . Then only you can see this is red.
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.