Answer the question
In order to leave comments, you need to log in
JavaFX how to change and update values in one of the columns of a table?
Good afternoon, tell me please. Out of curiosity, I came up with a problem.
Shortly speaking. In the database, I have a worker class (fields name, age, university, salary) and a student (but it doesn't matter).
In the program, I have a Person class, the Worker is inherited from it with identical fields.
I take all the employees from the database and create an ObservableList listAllEmployee. That is, the Worker class is prepared to create objects based on data from the database.
So I got the workers, brought everything out, and their salaries also came out.
TASK: in the combobox, if I select another currency, I need to update the Salary column immediately (there are currency data). But I don't know how to update Salary column as I need. It focuses on the Person class, and I don't want to store separate fields in Persone for salary in a different currency.
My currencies are stored in a separate class:
public class Currencies {
public static Currencies instance;
private float currencyOfDollar;
private float currencyOfEuro;
And I don't understand how can I force the Salary column to update its values when choosing another currency in the combobox?
This ill-fated column:
TableColumn salaryColumn = new TableColumn<>("Salary");
salaryColumn.setCellValueFactory(new PropertyValueFactory<>("salary"));
Let's say there is
Vasya in the table, salary 30000
Petya salary 50000
(in rubles)
I choose dollars in the combobox and so that 30,000 and 50,000 are immediately divided by the dollar rate (this data is already there) and the column would display as it should. But so as not to touch anything in the worker's class in the fields. And the column is able to focus only on the worker class, but nothing changes there and should not change. Only the output in the table should change. I hope I was able to express myself clearly. I'm new to this, I would appreciate it. Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question