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 perio
you can add an action listener on the button, then in its called function change the icon - here is an example :
public yourDialogSwing() {
Yourbutton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onButtonPressed();
}
});
}
private void onButtonPressed() {
YourButton.setIcon(YourButton.getPressedIcon());
}