I have looked and can not figure out how to format my TableColumn using a Double. It always ends up like 234.23232033 etc etc. I would like to to show 234.23 for example. I have seen post similar to mine, but I just cannot figure how to integrate it into my code. Partly my fault for maybe being to far ahead of what I actually know. But I would like to figure this out. Thank you.
Here is part of my Controller...
@FXML
private TableView<CheckBookData> tableView;
@FXML
private TableColumn<CheckBookData, String> transactionCol;
@FXML
private TableColumn<CheckBookData, Double> balanceCol;
ObservableList<CheckBookData> checkbook =
FXCollections.observableArrayList();
Double balance = 0.0;
public void initialize(URL url, ResourceBundle rb)
{
transactionCol.setCellValueFactory(new
PropertyValueFactory<CheckBookData, String>("transaction"));
balanceCol.setCellValueFactory(new PropertyValueFactory<CheckBookData,
Double>("balance"));
}
private void handleAddData(ActionEvent event)
{
Double deposit = Double.parseDouble(depositField.getText());
balance = balance + deposit;
checkbook.add(new CheckBookData(transaction, withdraw, deposit,
balance, checkNumber, date));
}
Here is part of my CheckBookData class...
public class CheckBookData
{
private SimpleStringProperty checkNumber, transaction, date;
private SimpleDoubleProperty withdraw, deposit, balance;
public CheckBookData(String transaction, Double withdraw, Double deposit,
Double balance, String checkNumber, String date)
{
this.transaction = new SimpleStringProperty(transaction);
this.withdraw = new SimpleDoubleProperty(withdraw);
this.deposit = new SimpleDoubleProperty(deposit);
this.balance = new SimpleDoubleProperty(balance);
this.checkNumber = new SimpleStringProperty(checkNumber);
this.date = new SimpleStringProperty(date);
}
public Double getBalance()
{
return balance.get();
}
public void setBalance(SimpleDoubleProperty balance)
{
this.balance = balance;
}