Answer the question
In order to leave comments, you need to log in
How to effectively communicate between classes?
Let's say I have a button class that gets all the paths to files in a folder and sorts them, and another button displays the file names. In the class with the first button, I have declared an ArrayList with file paths, how can I transfer this ArrayList but the second button class?
Answer the question
In order to leave comments, you need to log in
a button class that sorts something, another button class displays something ..... if it is effective, then rewrite this horror.
A button is a button, it does not have to do all this, you can hang a listener on it and catch the event, but do something about this event.
Logic and ui should be as loosely coupled as possible.
according to the classic user interface (buttons) -> do nothing, they only generate events, which are then processed by various kinds of workers (which sort or something else), and return the result somewhere.
this model has proved its effectiveness and is widely used.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question