r/JavaFX • u/MeanWhiskey JavaFX Fan • Jul 30 '24
Help Assigning a pattern to a textfield
I have a text field that I need to start with a certain sequence and that sequence increases by one number if a new person is entered.
For example the textfield would have a record number of '9913' and if a person is entered the textfields would clear but the record number would increase by one to '9914'.
1
Upvotes
View all comments
Show parent comment
1
u/direcorsair Jul 31 '24 edited Jul 31 '24
In whichever control you have to input a new person there will presumably be some sort of "Save" button/control. This control should provide an onAction event handler. So when you click the "Save" button a new person is input into what I presume is a database and you also simultaneously update the value in the TextField control with the new count.
That is the simplest method to achieve what you wanted. The more sophisticated approach is to use Observables. Read here for a breakdown on how those work.