Tengo un jframe en el que le doy click a un botón y este le pasa varios datos al otro jframe para que muestre dichos datos, el problema es que estos datos se borran, para cuando se muestra el otro jframe no se pueden visualizar esos datos y eso que el botón es el mismo que hace aparecer el otro jframe.
private void FacturarActionPerformed(java.awt.event.ActionEvent evt) {
int t = 0;
boolean Aprobado = true;
if (TablaVentas.getModel().getRowCount() == 0) {
JOptionPane.showMessageDialog(this, "No tiene repuestos disponibles", "Error", JOptionPane.ERROR_MESSAGE);
} else {
for (int i = 0; i < Modelo.getRowCount(); i++) {
if (TablaVentas.getModel().getValueAt(i, 0) == Boolean.TRUE) {
t++;
}
}
if (t == 0) {
JOptionPane.showMessageDialog(this, "Debe seleccionar un repuesto para poder facturar", "Error", JOptionPane.ERROR_MESSAGE);
} else {
for (int i = 0; i < Modelo.getRowCount(); i++) {
if (contador > 0) {
if (Modelo.getValueAt(i, 0) == Boolean.TRUE) {
try {
String SQL = "Update repuesto set estado=? where nombre=?";
ps = Conexion.prepareStatement(SQL);
ps.setBoolean(1, false);
ps.setString(2, (String) Modelo.getValueAt(i, 2));
ps.executeUpdate();
} catch (SQLException ex) {
Logger.getLogger(ventas.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else {
JOptionPane.showMessageDialog(this, "Seleccione un cliente o agregue uno nuevo", "Error", JOptionPane.ERROR_MESSAGE);
Aprobado = false;
break;
}
}
if (Aprobado == false) {
ORDENA();
} else {
int resp = JOptionPane.showConfirmDialog(this, "¿Está seguro?", "Alerta!", JOptionPane.YES_NO_OPTION);
if (JOptionPane.YES_OPTION == resp) {
new Ventas.VistaPrevia().setVisible(Aprobado);
this.setVisible(false);
new Ventas.VistaPrevia().RecogerDatosClientes(CamposCliente[2].getText(),
CamposCliente[1].getText(), CamposCliente[5].getText(), CamposCliente[3].getText(),
CamposCliente[0].getText(), CamposCliente[4].getText());
}
}
}
}
}
este es el código del otro jframe en donde quiero que se muestre los datos que le envio
public void RecogerDatosClientes(String nombrecli, String cedulacli, String direccioncli, String telefonocli, String tipoidentif, String correocli) {
for (int i = 0; i < 6; i++) {
switch (i) {
case 0:
Mostrardatoslabel2(i, 10, 10, "C.I./RIF./Pasp: ");
mostrardatoslabel(i, 108, 10, tipoidentif);
System.out.println(tipoidentif);
break;
case 1:
mostrardatoslabel(i, 120, 10, cedulacli);
System.out.println(cedulacli);
break;
case 2:
Mostrardatoslabel2(i, 10, 70, "Nombre Completo: ");
mostrardatoslabel(i, 130, 70, nombrecli);
System.out.println(cedulacli);
break;
case 3:
Mostrardatoslabel2(i, 670, 70, "Telefono: ");
mostrardatoslabel(i, 740, 70, telefonocli);
System.out.println(cedulacli);
break;
case 4:
Mostrardatoslabel2(i, 390, 10, "Correo: ");
mostrardatoslabel(i, 440, 10, correocli);
System.out.println(cedulacli);
break;
case 5:
Mostrardatoslabel2(i, 670, 10, "Direccion: ");
mostrardatoslabel(i, 740, 10, direccioncli);
System.out.println(cedulacli);
break;
}
}
}
public void Mostrardatoslabel2(int x, int y, int z, String r) {
Campos[x] = new JLabel(r);
Campos[x].setFont(new java.awt.Font("Times New Roman", 1, 14));
Campos[x].setForeground(new java.awt.Color(84, 19, 1));
Campos[x].setSize(150, 25);
Campos[x].setLocation(y, z);
jPanel3.add(Campos[x]);
jPanel3.revalidate();
jPanel3.repaint();
System.out.println(r);
}
public void mostrardatoslabel(int x, int y, int z, String r) {
CamposCliente[x] = new JLabel(r);
CamposCliente[x].setFont(new java.awt.Font("Times New Roman", 1, 14));
CamposCliente[x].setForeground(new java.awt.Color(0, 0, 0));
CamposCliente[x].setSize(1000, 25);
CamposCliente[x].setLocation(y, z);
jPanel3.add(CamposCliente[x]);
jPanel3.revalidate();
jPanel3.repaint();
System.out.println(r);
}
como se puede ver, yo muestro en un jpanel los datos como labels de forma dinámica