2
How to make the options of the comboBox
, correspond to numerical indexes? Example, in my bank I save only numbers from 1 to 8. And in the application I show my user names, I want these names to match those numbers. I was trying to use substrings
to do this.
1 -> A
2 -> B
3 -> C
4 -> D
5 -> AND
6 -> F
7 -> G
8 -> H
fill combo with the "names"
meuCombo.getItems().addAll("A", "B", "C", "D", "E", "F", "G", "H");
pojo.setDoPojo(meuCombo.getTypeSelector().substring(1 , 2))
Note: I just posted this snippet of code just to illustrate, I just want a direction of what to do, I’m not asking anything ready.
How so? , Do you want to pick up the items by position? for example item B in position 2 and so on?
– Anderson Henrique
Yeah, I’ll show you A, but I won’t "save" A, I’ll save 1.
– G1Win
this setDoPojo is where you save?
– Anderson Henrique
Each data entered in the combo box takes a position just like in the array, for example if you use the combobox.getItemAt( 0 ); returns A if you put 1 returns B and so on, couldn’t that be so? or necessarily has to start the A by 1?
– Anderson Henrique
@Andersonhenrique I already appreciate your attention, so I would have to start with the 1. setDoPojo is from the getters and setters of the pojo.
– G1Win
Since the database only stores the range 1-8 why not do index + 1?? Thus, selecting item "B" would be myCombo.getSelectionModel.getSelectedIndex() + 1 = 2, and 2 would be stored in the BD. Also not understood why store only 8 values in 1 database, an array would be sufficient.
– Gustavo Fragoso
Give me an example then, of how I should do, doing favor
– G1Win