You need to create an Actionlistener. it can be the GUI-Class itself (
button.setSelectionListener(this)
), or better a class beside the GUI-Element to do the logical part (
button.setSelectionListener(getGUIController());
)
Benefit: if you change the GUI Layout afterwards, the pogic remains untouched.
For Radiobutton you'll most likely need a
SelectionListener
or
SelectionAdapter
- I prefer the Listener-Pattern.
Tutorial on ActionListener[
^]