I do a program using swing. The point is that everything is interconnected in a class because of ActionListeners, then everything is in one file. Something to look for or change in it is extremely inconvenient. How to organize a class and remove all classes from it, but so that they see all the variables of my current class?

You can appreciate the scale of the tragedy here .

    1 answer 1

    You can either encapsulate the listeners into separate classes, and pass references to the necessary members of the class through the constructor. However, I would recommend that you use the event bus, it allows you to greatly reduce the connectivity of components in a gui application. A good basic implementation of EventBus is for example google guava.