N
N
Nickleft2018-03-24 22:38:18
Java
Nickleft, 2018-03-24 22:38:18

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

1 answer(s)
M
Maxim Moseychuk, 2018-03-25
@Nikleft

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 question

Ask a Question

731 491 924 answers to any question