I have always coded console applications and learned some basic UML / template skills using C ++.
Now I decided to switch to Java and add graphical interfaces to my programs.
The first question is how to handle the GUI layer in a program. I mean, how should I separate all the GUI code (adding components, handling main events) with the code that really does the job (for example, when you click a button).
Another issue related to EDT. I read that (almost) all Swing components must run on the same thread (usually EDT) due to the fact that they are not thread safe. Therefore, I thought that if he called "heavy code" (for example) ActionListener , then the graphical interface will stop responding for a while until the "heavy code" ends.
This is rather undesirable, so I think that the natural solution is to run heavy code, perhaps in a different thread or something like this (I know that this should be done carefully, because I could no longer assume that after the user clicked the button , "deep action" is performed before accessing another graphical interface).
So, as you can see, I have a lot of questions about how to include a graphical interface in my templates in order to keep everything completely independent and easily maintained; and some questions about specific things about Swing components and responsiveness.
source share