• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design question - events or observer

 
Ranch Hand
Posts: 51
Hibernate Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No for communication between frames, events are what you need.
reply
    Bookmark Topic Watch Topic
  • New Topic