This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I'm starting to get into Swing in my classes and I'm wondering how I can keep the GUI code and the processing code seperate. For example, I'm doing a Hw assignment right now. I've got a Homework2 class that is an Applet with a button. When you click the button it "starts" the homework. It's actually calling "new Layout();". The Layout class does the job of setting up the Swing GUI. I have other methods, but they all revolve around the interface (buildMenu(), buildMainArea(), etc). Then, I was hoping I could have another class called Controller that would be given control from event handlers in the Layout class. In the Controller class I could do whatever processing is needed, then return control back to Layout. The problem is I need to interact with controls from the Layout class and I don't have access to them. I've made them global public variables in Layout, but if I make too many cross references between classes, I get a load of runtime errors. So my question is this, how do you professional Swing developers keep your GUI code and processing code seperate? Thanks in advance!