Adding ActionListener to a Panel - Panel implements ActionListener vs Panel HAS A ActionListener

前端 未结 2 1881
温柔的废话
温柔的废话 2021-01-16 10:21

I made a panel for my program. It consists of RadioButtons only. When a radiobutton is selected, I want to set a boolean in other code. This panel will be used as a componen

2条回答
  •  萌比男神i
    2021-01-16 11:11

    Add a add/RemoveActionListener method to your panel. Use these as proxy to you radio button and register the ActionListener directly to it

    Alternatively, you could provide a isSelected method which returns the state of the radio button.

提交回复
热议问题