File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI and Processing, how to seperate?

 
Chris Stewart
Ranch Hand
Posts: 184
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Garandi Garandi
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Sloan Bowman
Ranch Hand
Posts: 107
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic