• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

GUI and Processing, how to seperate?

 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't gotten that deep into Swing yet. Can you describe it? Or maybe give a really good link?
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://martinfowler.com/eaaDev/OrganizingPresentations.html
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic