I have a program that detects when certain machines are online and creates a button with a green "online" icon to show this. I want to add the functionality to check periodically if this machine is still online, and if it's not, change the icon to the "offline" icon that I've already defined.
I know how to set the icon, however I can't figure out a way to do it once the button has already been displayed
probably you have issues with Concurency in Swing, that means that all Swing code must be done on EDT
then you have to wrap myButton.setIcon(myIcon)
to the invokeLater()
, for example
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
myButton.setIcon(myIcon);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With