Paul Clapham wrote:Speaking of JavaFX, it appears that this question is about JavaFX. So I've moved it into the JavaFX forum.
I don't know how I got it posted to General forums; I was thinking of JavaFX in the first place. Thanks for moving it!
I seem to have forgotten the basic idea behind TableView – it should be used only to
visualize data! I'm thinking about doing calculations within the class after all.
Still, to answer your questions, Dave:
1)
What class is returned by getValue? It returns the Expense class, which populates the table.
2)
And the associated unitPriceProperty or quantityProperty? These two are the price and quantity of the expense, so the table may look like this:
Name | Quantity | Unit price | Total price |
---|
Bicycle | 2.0 | $300.00 | $600.00 |
(yet I'm not sure if I understand your question.)
3)
Also, what does the code look like where you change either of those two values? These are changed based on user input. Again, if that's what you're asking for, the code looks as follows:
The thing is, like in the table above, my TableView displays the price with a currency, and each expense might have a different one. So, now I'm thinking about creating a custom class Price, which would store
value and
currency, which I could later extract for populating the table. Would it be better this way?
Another question is: is there a way to populate a column via a method? So, in other words, I'm thinking of calling a method like
calculateTotalPrice() instead of using a
propertyTotalPrice.
I hope it's not too much for one message...