File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI and Processing, how to seperate?" Watch "GUI and Processing, how to seperate?" New topic

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
[ 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
I agree. Here's the link:
subject: GUI and Processing, how to seperate?
It's not a secret anymore!