
Jcombobox problemas
Publicado por undertaker (61 intervenciones) el 07/09/2013 06:43:20
Buenas tengo problemas al pinchar en el combobox...resulta q quiero q el label marque el id
al ir cambiando el combobox se mantiene el id o marca 0
no se cual puede ser el problema si me pueden ayudar
al ir cambiando el combobox se mantiene el id o marca 0
no se cual puede ser el problema si me pueden ayudar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
try {
Producto p = new Producto();
ArrayList r;
Iterator iterador;
String nombre = this.combobox.getSelectedItem().toString();
if (evt.getStateChange() == ItemEvent.SELECTED) {
r = p.cargarProducto(nombre);
iterador = r.iterator();
while (iterador.hasNext()) {
c = (Producto) iterador.next();
int id = c.getId_prod();
this.label_prod.setText(String.valueOf(id));
}
}
} catch (Exception ex) {
.
.
.}
public ArrayList cargarCPU(String nombre) {
ArrayList r;
Producto p;
Conexion cdb = FactoriaServicios.getInstancia().getConexionDb();
cdb.un_sql = "SELECT id_prod,nombre,marca,capacidad FROM producto WHERE concat(marca,' ',nombre,' ',capacidad) = '" + nombre + "';";
cdb.resultado = cdb.un_st.executeQuery(cdb.un_sql);
if (cdb.resultado != null) {
r = new ArrayList();
while (cdb.resultado.next()) {
p = new Producto();
p.setId_prod(cdb.resultado.getInt("id_prod"));
p.setNombre(cdb.resultado.getString("nombre"));
p.setMarca(cdb.resultado.getString("marca"));
p.setCapacidad(cdb.resultado.getFloat("capacidad"));
r.add(p);
}
} else {
throw new MyError(-1, "Consulta a tabla producto ha devuelto un recordset null Ubicación=" + this.getClass().getName());
}
return r;
}
Valora esta pregunta


0