Fill in Jtextfield from jComboBox

Asked

Viewed 10 times

0

I have a. txt file with strings like this:

luis;123;456;789;11/11/1111

The first part of my problem was popular jComboBox only with the first value (name), I managed to do some good, but now I need a jTextField changes to the third value as I change the selection on jComboBox. Below is how I populated the combobox, but I have no idea how to make the textfield to be filled as I alternate the selection of the combobox.

DefaultComboBoxModel<String> ComboClientes;

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];  
                ComboClientes.addElement(nome);                    
            }
           br.close();
           fr.close();
           jComboBoxCliente.setModel(ComboClientes);
        }
  • I’m not seeing the jTextField to be completed.

  • It’s all done in a jFrame, I haven’t edited anything from the jTextField code yet because I don’t know what to do to set the text as the combobox is selected.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.