Display elements of Jcombox to a Jtable

0

Best regards I have a jcombobox mat_codigo, mat_des, mat_preciovta I need to pass the values to a table as the description in column (1) and the price vta in the coulman (3) as it is in the image

My code is the following:  public void ShowComboBoxCategoria () {      DefaultComboBoxModel value1;      try {             Statement sent = Conn.createStatement ();

     String sql = "select mat_codigo,mat_des,mat_preciov from materiales order by mat_codigo asc";
     ResultSet rs = sent.executeQuery(sql);

      value1 = new DefaultComboBoxModel();
     cmb_cat.setModel(value1);

     while (rs.next()) {
         value1.addElement(new CmbObtener(rs.getString("mat_des"), rs.getString("mat_codigo"),rs.getString("mat_preciov")));

     }
       rs.close();
      Conn.close();
    } catch (Exception ex) {
        System.out.println(ex.getCause());

    }}

public class CmbObtain {

private String datoItem;
private String id;
private String preciov;

public CmbObtener(String datoItem, String id,String preciov) {
    this.datoItem = datoItem;
    this.id = id;
    this.preciov=preciov;
}

public String getID() {
    return id;
}

public String toString() {
    return datoItem;
}
public String getpreciov() {
    return preciov;
}


}

But the jcombox is not visible in the table. I appreciate your cordial support.saluds

    
asked by Victor Perales 23.12.2017 в 03:05
source

1 answer

0

Well I found a quick solution by editing the Table contents and add to the custom code of the editor of the jtable

new javax.swing.DefaultCellEditor (cmb_cat), now it visualizes the element of my table in the Database, but I need to send to column 03 of the jtable the sales price as shown in the figure.

    
answered by 23.12.2017 в 03:32