The reason the ChangeListener
isn't working in your 1st approach, is that your listener reference sizeAction
is null
when you register the listener.
slider.addChangeListener(sizeAction);
While this won't throw an exception, it won't register the listener when it is instantiated.
Simply alllow this line to appear after you define the listener and it will start working.
If you wish to use your other ChangeListener
implementation instead you can use:
slider.addChangeListener(this);