This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes GUI�s, OO, events and decoupling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "GUI�s, OO, events and decoupling" Watch "GUI�s, OO, events and decoupling" New topic
Author

GUI�s, OO, events and decoupling

h slater
Greenhorn

Joined: Nov 22, 2002
Posts: 13
I am constructing a small application that consists of the following principal classes:
A Gui class that includes instances of 3 custom panel classes
An Adapter class that has a reference to the interface of the gui class
A Calculation class that has a reference to the interface of the adapter class
An Application class that sets which gui class and adapter class to use and sets it all in motion
The architecture of the application pleases me (it is closely based on OOPad - an example of using OO in java by a certain Richard Harris)
The Calculation Class includes a method in its constructor to get an array of references to components from the gui classes. These are then �unpacked� and class cast to their type (eg: JSlider etc�)- the new values are then updated [sorry if terminology not always correct � new to programming]
All of this works very well and is cleaner than it sounds when explained. However, I want to have only values being sent out of the GUI (strings, doubles and ints) so that the Calculation Class is not so dependant on the choice of components that are used to construct the gui.
Calculate Class could implement PropertyChangeListener (or some custom ChangeEvent interface) and be added to the gui components to get new values. However, I�m unsure what the cleanest method for updating the gui components with new values would be.
I�m sure that this is a situation that occurs frequently so I�d be interested in suggestions for �best practice�
Cheers
Hugh
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Do you know the Model View Controller pattern?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
h slater
Greenhorn

Joined: Nov 22, 2002
Posts: 13
yes - but have follow questions
but have "moved" the question to the OO Patterns forum
thanks
Hugh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI�s, OO, events and decoupling