I want to sum the ObjectProperty<BigDecimal>
values of a JavaFX TableColumn
. I've used this question as a reference. The problem is my implementation of it as shown here:
private void doSalesTotals() {
olSales.addListener(new ListChangeListener<Sales>() {
@Override
public void onChanged(Change<? extends Sales> change) {
while (change.next()){
if (change.wasAdded()){
for (Sales s : change.getAddedSubList()){
totalWithDiscount.set(totalWithoutDiscount.get().add(s.getAmount()));
System.out.print(totalWithDiscount);
}
} else if (change.wasRemoved()){
} else if (change.wasReplaced()){
} else if (change.wasUpdated()){
}
}
}
});
keeps giving me a nullpointer exception and no currency addition takes place.
Some context: The table is part of a POS module I'm doing for my 4th year Undergraduate project.
What exactly am I doing wrong and how do I solve it?