Search code examples
javanetbeansseparation-of-concerns

Java, Netbeans and separation of concerns


I am new to Java and Netbeans, and want to write a Swing project to learn by.

Naturally I want to separate the "guts" of the code from the GUI class. How should I go about it, best practice ?

Should I:

  1. Use public static void main(String[] args) in the GUI class. Then create an instance of a "controller". Calling controller functions via GUI events (passing only data) ?
  2. Use public static void main(String[] args) in the "controller", and pass an instance of the controller to the GUI class ?

Create instances, or use classes statically ? And what of this invokeLater business ?

[ some little code samples would be lovely ]

Thanks. Anthony.


Solution

  • Three: Put main() in its own class and intitialize all objects as needed.