How to call data from a table to a textfield

0

I want to send customer data to show them when making a purchase, you must show the customer's name and rfc, my code if it captures and shows, but at the time of showing it only shows the last rfc entered, so the rfc do not match with each customer. What I want to achieve is that the user can select the client from a combo box and in a textfield the rfc of the previously captured client appears automatically.

This is my code:

ArrayList<Cliente>listaclientes = new ArrayList<Cliente>();
ArrayList<Producto>listaproducto = new ArrayList<Producto>();
ArrayList<Proveedor>listaproveedores = new ArrayList<Proveedor>();
ArrayList<Cliente>listacompras = new ArrayList<Cliente>();    
private void añadirclienteatabla(){
    Cliente cliente = new Cliente (jTextField1.getText() , jTextField2.getText(),jTextField3.getText(),jTextField4.getText(),jTextField5.getText());
    listaclientes.add(cliente);
    TablaClientes.addRow(new Object[]{cliente.getNombre(),cliente.getApellido(),cliente.getFecha(),cliente.getRfc(),cliente.getDireccion()});
    ventana();

}
private void añadirproductotabla(){
    Producto producto = new Producto (jTextField6.getText(),jTextField7.getText(),jTextField8.getText());
    listaproducto.add(producto);
    TablaProductos.addRow(new Object[]{producto.getNombre(),producto.getCodigo(),producto.getPrecio()});
    ventana2();
}
private void añadirproveedortabla(){
    Proveedor proveedor = new Proveedor (jTextField9.getText(),jTextField10.getText(),jTextField11.getText());
    listaproveedores.add(proveedor);
    TablaProveedores.addRow(new Object[]{proveedor.getNombre(),proveedor.getRfc(),proveedor.getDireccion()});
}
private void addCliente2Combo()
{
    String pos = jTextField1.getText();
    jComboBox1.addItem(pos);

}
private void addProducto1Combo(){

    String pos = jTextField6.getText();
    jComboBox2.addItem(pos);
}
private void addProveedorCombo(){
    String pro = jTextField10.getText();
    jComboBox3.addItem(pro);
}
private void addPrecioLabel(){
     double cantidad=Double.parseDouble(this.cantidad1.getText().trim());
     double precio = Double.parseDouble(this.jTextField8.getText().trim());
     double d = cantidad*precio;
      this.jTextField12.setText(String.valueOf(d));// muestra total
     double dinero = Double.parseDouble(this.pago.getText().trim());



     double cambio = dinero-d;
     this.jTextField13.setText(String.valueOf(cambio));// muestra cambio
}
private void addRfc(){
    double Rfc = Double.parseDouble(this.jTextField4.getText().trim());
    this.jTextField14.setText(String.valueOf(Rfc));
}
    
asked by Daniel Alberto Trujillo 09.06.2018 в 19:47
source

0 answers