• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable: updating cells programitcally

 
Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2 of the columns in my JTable hold monetary values ( double).
If the value in cell A changes, then value B should be updated with the result of a calculation performed using the new value in A and the old value in B.
Sort of like a spreadsheet.
I can't seem to set the new value of A for use in a simple calculation.

At present my code is as follows:
[edited to remove those evil tab characters -ds ]
[ October 18, 2002: Message edited by: Dirk Schreckmann ]
 
Bill Liteplo
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried your code, but I think there are more conventional ways to solve your problem that are [BOLD]much[/BOLD] simpler.
something like this:


Basic idea:
1. there is some data that are stored in your cache object
2. there is a GUI object (e.g. JTable) that is the interface, but does not store the data
3. you use a model (e.g. TableModel) to control the data and interface between the data cache and the view
I'm sure other people could list numerous resources on this Design Pattern.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!