Answer the question
In order to leave comments, you need to log in
How to use non-nested classes in Swing?
For example, there is a class with a main interface in Swing and objects with which you need to work. There are separate classes in which there are methods. How to add a listener to a specific button that will call the method of another class and work with objects of the main class? Simply put, I want to divide it into classes with functionality and an interface.
Answer the question
In order to leave comments, you need to log in
Create a listener, in the constructor of which to pass references to objects with which you want to work.
In Scala/Kotlin/Clojure and other slightly more modern languages, this is easily solved through closures.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question