when you create a gui application in netbeans IDE,
it generates 2 files, the App.java and View.java
is it okay to include the application logic in view.java ? my intuition tells me this is a bad idea. However, I don’t know how I can call the methods or somehow “hook” the App.java with View.java
So instead of having to put all my code for the actionPerformed on a button, I would just insert a method from App.java
I am quite new to Java. If someone has a good tutorial or book on Netbeans, I think I will buy it.
Another good approach is to learn and use Action Classes. See How to Use Actions
Such a Action class encapsulates a unit of work (“login”,”print”,…) and you simply attach it to one or more gui elements (JButton, JMenu, …). If you use this concept, your application can grow more easily. Separating application logic, GUI and data is always a good idea.
A incomplete Example
To use this, you need to create/fetch a instance of the Action within your view and attach it to e.g. a JButton with