Segregate java codes in eclipse

-4

I would like to know:

  • How do I segregate the codes of the elements added (button, label ...) in form and their events in eclipse using the JAVA language?

In java all the element code (button, label ...) added in the views and their events are in a class. I only see a disadvantage in this (readability, maintenance ...).

InVisualStudiowhenprogramminginC#thisisalreadydoneautomatically.Inittwoclassesarecreated.Oneonlywiththecomponentsoftheviewandthesecondonewiththeeventstheprogrammerwantstomanipulate.

    
asked by anonymous 01.06.2018 / 05:48

1 answer

-1

Your question seems more about how to make the IDE generate segregated code, in this case, Eclipse?

If not, you can simply create the separate class and set it as an argument to addActionListener .

But each language has its own styles, and they make sense. In the concrete case of your example, the content of an ActionListener is rarely reusable code. What's more, the code usually only makes sense where it was added, and usually has few lines of code.

Based on this, I would disagree that the code is unreadable or difficult to maintain. In that case, of course. Other cases may be different.

    
01.06.2018 / 10:56