There are several patterns in Java Swing development.
Is there a way to generate this code automatically in IDEA, or are these good ideas for Intentions?
Swing uses callbacks to notify when a button is pressed, an item is selected, focus is lost, etc. One strategy is to have your GUI panel implement the listener class, but I don't like this because you have to advertise the callbacks as public methods of your class which pollutes your class interface. So, I usually just use anonymous classes. Here is some example code:
It would be nice to have an intention when the caret is at:
with choices like "Create inline anonymous class implementing ListSelectionListener" or "Create named anonymous class implementing ListSelectionListener". This could be shortened to just "Create inline ListSelectionListener" and "Create named ListSelectionListner".
This intention could be applied to any class which has a constructor with Zero arguments. (A requirement of anonymous classes)