I need help with this:
I have a .txt file with strings like luis;123;456;890;11/11/1111, from this I needed to fulfill a combobox with just the position 0 (luis, on this example), and I've done it! But as I select the option from combobox I also need to fill a text field with position 2 of the string referring to the line selected on the combobox. What should I do?
Code for filling combobox:
DefaultComboBoxModel<String> ComboClientes;
public JFrameRegVendas() {
initComponents();
}
public void popularCombo() throws FileNotFoundException, IOException{
ComboClientes = new DefaultComboBoxModel<>();
String clientes = "";
FileReader fr;
fr = new FileReader("clientes.txt");
BufferedReader br = new BufferedReader(fr);
while ((clientes = br.readLine())!=null){
String quebra [] = clientes.split(";");
String nome = quebra[0];
String cpf = quebra[2];
ComboClientes.addElement(nome);
}
br.close();
fr.close();
jComboBoxCliente.setModel(ComboClientes);
}