wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes GUI and Processing, how to seperate? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI and Processing, how to seperate?" Watch "GUI and Processing, how to seperate?" New topic
Author

GUI and Processing, how to seperate?

Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
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!
Garandi Garandi
Ranch Hand

Joined: Jan 07, 2003
Posts: 192
Use MVC(Model, View, Controll) or MVP Pattern, and use observer and observalbe for Model and view.
Thank you
Garandi
[ June 15, 2003: Message edited by: Garandi Garandi ]
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I haven't gotten that deep into Swing yet. Can you describe it? Or maybe give a really good link?
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
http://martinfowler.com/eaaDev/OrganizingPresentations.html
 
Consider Paul's rocket mass heater.
 
subject: GUI and Processing, how to seperate?
 
Similar Threads
SCJD: Swing Architecture
Threads/ActionListeners
GUI Design
Inter-Component communication in Swing
Identifying which button in array is pressed