AFAIK you cannot, because it ActionListenerwill be created first and at that time must have access to a final variable loginthat is not yet initialized.
The order of calls will be as follows:
- create instance
ActionListener - pass this instance to the constructor
LoginFrame login
, ActionListener login - .
, , ActionListener, i.e.
final LoginFrame login = new LoginFrame();
login.addActionListener( new ActionListener() { ... } );