This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design question - events or observer

 
Gene Hilpert
Ranch Hand
Posts: 51
Eclipse IDE Hibernate Oracle
  • 0
  • 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
 
Campbell Ritchie
Sheriff
Pie
Posts: 47281
52
  • 0
  • 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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • 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
  • 0
  • 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
Sheriff
Pie
Posts: 47281
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No for communication between frames, events are what you need.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic