Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI�s, OO, events and decoupling

 
h slater
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know the Model View Controller pattern?
 
h slater
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes - but have follow questions
but have "moved" the question to the OO Patterns forum
thanks
Hugh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic