Dynamically change jButton icon

后端 未结 5 1299
Happy的楠姐
Happy的楠姐 2021-01-19 22:14

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

5条回答
  •  生来不讨喜
    2021-01-19 22:18

    I have a program that detects when certain machines are online and creates a button with a green "online" icon to show this.

    Use a JToggleButton instead, as shown here1 & here2.

    I can't figure out a way to do it once the button has already been displayed.

    To toggle the state and fire an action event doClick() or alternately setSelected(boolean).

    Screenshots

提交回复
热议问题