Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Design question - events or observer  RSS feed

 
Ranch Hand
Posts: 51
Eclipse IDE Hibernate Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a java desktop application to learn java (it is an application to handle boy scout memberships)
and have hit design question.
I have a main jframe that has a jtable that holds checkbook records,
then I have another jframe with another jtable that will hold budget items for a check.
Ex. in the first table
check #100, summer camp, 2008, $1000.00
check #101, charter fees, 2008, $650.00
in the second table you have for check #100
200.00, gas
800.00, fees
for check #101
650.00, fees

What I want is when you scroll thru the first table the second table change as well.

Ex. when you are in the first record in the first table(#100) the second one shows
200.00, gas
800.00, fees
when you scroll to the second record the first table(#101) the second one shows
650.00, fees

I'm looking at two ways to do this
1) using events
2) using observable and observer

Any ideas on the best way or a third way?

Also there will be other jframes that will do things similar to the second jframe
(what members accounts are debited or credited with this check.)( I put the tables in
separate frames to be able to turn then off)

Thanks
 
Marshal
Posts: 60127
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you are not describing a database? Sounds like the sort of thing people do every day in SQL.
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact, events and the Observer pattern are basically the same thing. And they sound like a good solution to your problem - updating one part of the GUI based on actions in a different part.
 
Gene Hilpert
Ranch Hand
Posts: 51
Eclipse IDE Hibernate Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using embedded Javadb as a DB.
The queries are no problem. I just wanted to know if I was missing something better to communicate between the frames.

Thanks
 
Campbell Ritchie
Marshal
Posts: 60127
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No for communication between frames, events are what you need.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!