• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hiding the actual data values in the DataModel when displaying with JTable  RSS feed

Jon Swanson
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application that keys off the values in a column in my table. A new requirement is that the GUI have an option to change the units in that column. One thought I had to satisfy this new requirement was to modify the cell editor and cell renderer. So if I did a getValue on the table, I'd always get the same value, but the user would see values scaled in the units they requested. The code is below. It's not my only choice. I could also modify getValue and setValue to do the conversion. Or I could modify all the classes and methods that currently expect specific units. I like the idea of handling the conversion early, but I am wondering if anyone has comments on the 'best practices' way of handling this. And also, if my code is not right, suggestions to improve it.

If you run it, just type a number in the cell. Set Scale doubles the scale every time you press it, while Press Here gives the value in the model.

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!